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];

最新文章

  1. webix前端架构的项目应用
  2. 【Java每日一题】20161226
  3. 【数据结构】红黑树 C语言代码
  4. Guacamole 介绍以及架构
  5. 巧用 .NET 中的「合并运算符」获得 URL 中的参数
  6. C#读取Word模板替换相应的字符串(标签)生成新的Word
  7. 【Android 复习】:第02期:引导界面(二)使用ViewPager实现欢迎引导页面
  8. 5事件DOM零级事件跟DOM二级事件
  9. Linux平台Makefile文件的编写基础篇(转)
  10. JavaScript 变量类型 保存内存中的位置 和 引用
  11. VirtualBox镜像复制载入
  12. django email用法
  13. 大数据测试之hadoop集群配置和测试
  14. eclipse和android studio的目录结构分析
  15. CAN通信要注意的问题
  16. 第29月第27天 Error: Multiple commands produce
  17. 【论文速读】Chuhui Xue_ECCV2018_Accurate Scene Text Detection through Border Semantics Awareness and Bootstrapping
  18. 数据结构——基于java的链表实现(真正理解链表这种数据结构)
  19. 学习任务,阅读一下Redis分布式锁的官方文档
  20. hdu-5536(字典树)

热门文章

  1. jquery扩展方法
  2. SSH整合创建SessionFactory
  3. [原创*精华]一键发布ASP.NET Web安装程序,搞WebForm的童鞋看过来...
  4. 在C#中模拟Javascript的setTimeout方法
  5. C#5.0支持的await格式
  6. JS,CSS是前端,JAVA PHP ASP是后端,数据库是后端的处理对象,非代表前后底
  7. Ubuntu下JDK+Tomcat+MySql环境的搭建
  8. 【汇编语言】DEBUG的使用
  9. 使用CATransformLayer制作3D图像和动画
  10. 使用prismjs为网站添加代码高亮功能