iOS label button等设置不同颜色的标题
来源:互联网 发布:数控铣削编程实例简单 编辑:程序博客网 时间:2024/05/18 18:01
label
[[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String"];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,5)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:30.0] range:NSMakeRange(0, 5)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0] range:NSMakeRange(6, 12)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:30.0] range:NSMakeRange(19, 6)];
attrLabel.attributedText = str;
button
_button = [UIButton buttonWithType:(UIButtonTypeCustom)];
_button.frame = CGRectMake(200, 200, 100, 20);
_button.backgroundColor = [UIColor redColor];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"你是好人"];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0,2)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(2,2)];
[_button setAttributedTitle:str forState:(UIControlStateNormal)];//此处注意是这个方法
[self.view addSubview:_button];
- iOS label button等设置不同颜色的标题
- iOS同一label设置不同颜色
- iOS设置同一个Label的不同颜色的字体
- iOS 一个label现实不同颜色的字体
- 设置label不同颜色
- iOS 设置label button的文字显示几种颜色
- 同一个label设置不同颜色文字
- label设置不同颜色 不同字体
- ios Label显示不同颜色文字
- 如何设置在一个Label上显示不同颜色的text
- iOS开发 label上显示不同颜色不同大小的字
- iOS 一个label中显示不同颜色的文字
- iOS在一个label中显示不同颜色的字体
- iOS在一个Label中展示不同颜色的text
- iOS 关于label上显示不同颜色的字体
- iOS中xib设置label等的圆角
- c#设置button、label等控件的背景色为透明
- 设置Button的标题偏移
- sublime text 3 + python配置,完整搭建及常用插件安装
- Java学习笔记(71)----------volatile
- ios动画效果
- iOS 收回键盘的3个方法
- 新奔腾PT2008工程计价软件下载 v8.0.24
- iOS label button等设置不同颜色的标题
- iOS开发系列--UITableView全面解析
- 关于Myeclipse出现 java文件中文乱码问题的解决方案.
- dsp指令
- linux 进程前后台切换
- freemaker的word文档导出实例使用
- 括号匹配
- 橄榄山快模(revitkm)下载 v3.1
- 比较日期大小的两种方式