UILabel *Label = [[UILabel alloc] initWithFrame:CGRectMake(20, 300, 300, 30)];

NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"set background color with button"];

[string addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,2)];

[string addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)];

[string addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)];

[string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:17.0] range:NSMakeRange(0, 5)];

[string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:17.0] range:NSMakeRange(6, 12)];

[string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:17.0] range:NSMakeRange(19, 6)];

Label.attributedText = string;

[self.view addSubview:Label];

   效果图 :  set background color with button

最新文章

  1. [Android]AndroidInject增加sqlite3数据库映射注解(ORM)
  2. monkeyrunner之环境搭建及实例(三)
  3. [Linux]CentOS下安装和使用tmux
  4. Leetcode-121 Best Time to Buy and Sell Stock
  5. 【转】mac/linux终端光标的快捷键操作
  6. CentOS 7 firewalld使用简介
  7. FPGA控制HC595
  8. 剑指Offer45 约瑟夫环
  9. Asp.net主题(theme)和皮肤(skin)的使用
  10. 杭电dp题集,附链接还有解题报告!!!!!
  11. 2108 ACM 向量积 凹凸
  12. centos6.5安装jdk(解压tar.gz)
  13. C# 随机四位数验证码
  14. myeclipse部署项目的时候报No projects are available for deployment to this server但是项目明明存在
  15. input 内容改变的触发事件
  16. 1. 通俗易懂解释知识图谱(Knowledge Graph)
  17. 双机\RAC\Dataguard的区别
  18. SYS_R12 MOAC多组织底层技术实现技术分析(Oracle VPD) (案例)
  19. 【SP2713 GSS4 - Can you answer these queries IV】 题解
  20. 玩一下易语言 "和"字有多种读音,注定了它的重要性!!

热门文章

  1. android源码mk文件里的TARGET_OUT指向哪里?
  2. 创建微服务项目后,在谷歌、Safari等浏览器下无法访问的具体原因
  3. hdu4888 多校B 最大流以及最大流唯一判断+输出方案
  4. Wannafly挑战赛11 D 题 字符串hash + 卡常
  5. log4j配置(转载)
  6. spark学习(六)Java版RDD基本的基本操作
  7. spark学习(五)总结及其demo
  8. FFT/NTT模板 既 HDU1402 A * B Problem Plus
  9. TreeView 与 ListView
  10. 【POJ 3292】 Semi-prime H-numbers