美文网首页
UILable设置多种字体、颜色

UILable设置多种字体、颜色

作者: 舒耀 | 来源:发表于2015-09-21 15:12 被阅读199次
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"3569位家认证医院的17539位咨询师期待您的加入"];
[str addAttribute:NSForegroundColorAttributeName value:RGBCOLORA(255, 255, 255, 0.5) range:NSMakeRange(0,str.length)];
[str addAttribute:NSForegroundColorAttributeName value:RGBCOLORA(121, 210, 190, 0.3) range:NSMakeRange(0,4)];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:40] range:NSMakeRange(11, 5)];
[str addAttribute:NSForegroundColorAttributeName value:RGBCOLORA(121, 210, 190, 0.3) range:NSMakeRange(11,5)];

Lable.attributedText = str;

运行效果预览


Paste_Image.png

其中

NSMakeRange
NSMakeRange(NSUInteger loc, NSUInteger len) 从第几个字符到多少个字符间,即length

相关文章

网友评论

      本文标题:UILable设置多种字体、颜色

      本文链接:https://www.haomeiwen.com/subject/zjkicttx.html