NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"hello world hello world"];
[str addAttribute:NSFontAttributeName
value:[UIFont boldSystemFontOfSize:20]
range:NSMakeRange(6, 5)];
[str addAttribute:NSBackgroundColorAttributeName
value:[UIColor greenColor]
range:NSMakeRange(6, 5)];
[str addAttributes:@{NSForegroundColorAttributeName:[UIColor redColor],
NSFontAttributeName:[UIFont boldSystemFontOfSize:26],
NSBackgroundColorAttributeName:[UIColor lightGrayColor]}
range:NSMakeRange(12, 5)];
label.attributedText = str;
一个UILabel上显示不同的字体、颜色
最新推荐文章于 2017-04-06 18:10:12 发布