label 不同颜色
label 不同颜色
UILabel* noteLabel = [[UILabel alloc] init];
noteLabel.frame = CGRectMake(60, 100, 200, 100);
noteLabel.textColor = [UIColor blackColor];
noteLabel.numberOfLines = 2;
NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:@"点击注册按钮,即表示您已同意隐私条款和服务协议"];
NSRange redRange = NSMakeRange([[noteStr string] rangeOfString:@"注册"].location, [[noteStr string] rangeOfString:@"注册"].length);
[noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange];
NSRange redRangeTwo = NSMakeRange([[noteStr string] rangeOfString:@"同意"].location, [[noteStr string] rangeOfString:@"同意"].length);
[noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:redRangeTwo];
[noteLabel setAttributedText:noteStr];
[noteLabel sizeToFit];
[self.view addSubview:noteLabel];
最新文章
- webix前端架构的项目应用
- 【Java每日一题】20161226
- 【数据结构】红黑树 C语言代码
- Guacamole 介绍以及架构
- 巧用 .NET 中的「合并运算符」获得 URL 中的参数
- C#读取Word模板替换相应的字符串(标签)生成新的Word
- 【Android 复习】:第02期:引导界面(二)使用ViewPager实现欢迎引导页面
- 5事件DOM零级事件跟DOM二级事件
- Linux平台Makefile文件的编写基础篇(转)
- JavaScript 变量类型 保存内存中的位置 和 引用
- VirtualBox镜像复制载入
- django email用法
- 大数据测试之hadoop集群配置和测试
- eclipse和android studio的目录结构分析
- CAN通信要注意的问题
- 第29月第27天 Error: Multiple commands produce
- 【论文速读】Chuhui Xue_ECCV2018_Accurate Scene Text Detection through Border Semantics Awareness and Bootstrapping
- 数据结构——基于java的链表实现(真正理解链表这种数据结构)
- 学习任务,阅读一下Redis分布式锁的官方文档
- hdu-5536(字典树)
热门文章
- jquery扩展方法
- SSH整合创建SessionFactory
- [原创*精华]一键发布ASP.NET Web安装程序,搞WebForm的童鞋看过来...
- 在C#中模拟Javascript的setTimeout方法
- C#5.0支持的await格式
- JS,CSS是前端,JAVA PHP ASP是后端,数据库是后端的处理对象,非代表前后底
- Ubuntu下JDK+Tomcat+MySql环境的搭建
- 【汇编语言】DEBUG的使用
- 使用CATransformLayer制作3D图像和动画
- 使用prismjs为网站添加代码高亮功能