去掉segMentedControl的边框和改变选中字体的样式

一、初始化

//初始化  并赋值 UISegmentedControl *segmentControl = [[UISegmentedControl alloc]initWithItems:@[@"头条",@"体育",@"新闻",@"科技",@"娱乐"]];

//给segmentControl一个位置  让它显示

 segmentControl.frame = CGRectMake(0, 60, CGRectGetWidth([UIScreen mainScreen].bounds), 50);

 [self.view addSubview:segmentControl];

二、清除掉边框颜色  此时会清除掉所有文字

 segmentControl.tintColor = [UIColor clearColor];

三、先初始化字典 设置字体后  便解决了所有问题

NSDictionary *dicOne = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:20],NSForegroundColorAttributeName:[UIColor blackColor]};

四、把字典的值  给segmentControl  注意 setTitleTextAttributes 需要一个字典

[segmentControl setTitleTextAttributes:dicOne forState:UIControlStateNormal];

五、选中状态同样

 NSDictionary *dicTwo = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:25],NSForegroundColorAttributeName:[UIColor redColor]};

[segmentControl setTitleTextAttributes:dicTwo forState:UIControlStateSelected];
时间: 2024-08-24 10:51:24

去掉segMentedControl的边框和改变选中字体的样式的相关文章

UISegmentedControl 改变选中字体的颜色

//设置选中的字体颜色为蓝色    [segmentControll setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor]} forState:UIControlStateSelected];        //设置未选中的字体颜色为白色    [segmentControll setTitleTextAttributes:@{NSForegroundColorAttributeName : [UI

C# WinForm 拖动无边框窗体 改变无边框窗体尺寸

经常遇到这种情况.窗体的边框去掉了.然后种种问题就出来了:不能拖动.不能改变窗体大小.不能......当然.肯定有解决方案滴*^_^*今天的目标就是:可以直接拖动没有边框的窗体.可以直接拉拽窗体改变其大小.制作步骤如下:新建WinForm程序.添加一个启动的窗体.将其边框设置为None.进入代码编辑界面.定义如下常量值: const int Guying_HTLEFT = 10; const int Guying_HTRIGHT = 11; const int Guying_HTTOP = 12

IOS总结_IOS7.0以后改变状态栏字体颜的问题

首先info.plist文件中,加入View controller-based status bar appearance项 如果设为YES,则View controller对status bar的设置优先级高于application的设置:设置为NO则以application的设置为准. 虽然7.0SDK后在UIViewController中也加入加入了 - (UIStatusBarStyle)preferredStatusBarStyle NS_AVAILABLE_IOS(7_0); //

改变选中区域的文字和背景颜色

很多个人网站都会改变选中区域的文字和背景的颜色,今天偶然看到的,就想了一下,想到了系统默认事件(system default),想到了jQuery的Sizzle选择器,貌似都搭不上边,其实很简单,用CSS3的伪元素选择器::selection就好了. .demo::selection{color:#fff;background:#ff5e2c;} .demo::-moz-selection{color:#fff;background:#ff5e2c;} .demo::-webkit-select

分割窗口,拖动窗口边框可以改变窗口大小

public class Demo2 { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("分割窗口,拖动窗口边框可以改变窗口大小"); shell.setLayout(new FillLayout()); SashForm form = new SashForm(shell, SWT.HOR

去掉textarea的边框和右边的滚动条

去掉textarea的边框和右边的滚动条 tarea   name= "textarea "   cols= "100 "   rows= "4 "   style= "BORDER-BOTTOM:   0px   solid;   BORDER-LEFT:   0px   solid;   BORDER-RIGHT:   0px   solid;   BORDER-TOP:   0px   solid;overflow-y:hidde

linux终端c语言改变输出字体颜色

Linux下C改变输出字体颜色 例: #include int main() { printf("\033[31mThis is RED.\n\033[0m"); return 0; } 31m代表字体为红色,0m代表关闭所有属性. 常用的ANSI控制码如下(有些不支持): \033[0m 关闭所有属性 \033[1m 高亮 \033[2m 亮度减半 \033[3m 斜体 \033[4m 下划线 \033[5m 闪烁 \033[6m 快闪 \033[7m 反显 \033[8m 消隐 \

修改eclipse中java和xml页面的字体的样式

代码编辑界面默认颜色为白色.对于长期使用电脑编程的人来说,白色很刺激我们的眼睛,所以改变workspace的背景色,可以使眼睛舒服一些.设置方法如下: 1.打开window / Preference,弹出Preference面板  2.展开General标签,选中Editors选项,展开.  3.选中 Text Editors,右边出现TestEditors面板. 面板中有这样一个选项:Appearance color options:其中是各种板块颜色的设置,其中有一项是background

改变滑动删除按钮样式

在自定义 cell 中实现如下代码: // 改变滑动删除按钮样式 - (void)layoutSubviews { [super layoutSubviews]; for (UIView *subView in self.subviews){ if([subView isKindOfClass:NSClassFromString(@"UITableViewCellDeleteConfirmationView")]) { CGRect cRect = subView.frame; cRe