美文网首页
label的富文本

label的富文本

作者: 9bf19a4010ab | 来源:发表于2017-06-29 11:18 被阅读7次

最近写东西发现一些小东西就在手边却写不出来 得记录一下

NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:@"哈哈哈哈哈123456789"];

// 修改富文本中的不同文字的样式
[attri addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0, 5)];
[attri addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:NSMakeRange(0, 5)];

// 设置数字为红色
[attri addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(5, 9)];
[attri addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(5, 9)];

textLabel.attributedText = textStr;

To Be Continued...

相关文章

网友评论

      本文标题:label的富文本

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