NSMutableAttributedString富文本使用
作者:
哈利波特会魔法 | 来源:发表于
2018-07-17 10:25 被阅读0次 UILabel *label = [[UILabel alloc] init];
NSString *wordStr = @"i-Do-Not-Like-The-Word-I-Only-Like-You";
label.text = wordStr;
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:wordStr];
NSRange range = [wordStr rangeOfString:@"I"];
[attStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(range.location, wordStr.length - range.location)];
label.attributedText = attStr;
本文标题:NSMutableAttributedString富文本使用
本文链接:https://www.haomeiwen.com/subject/ojkwpftx.html
网友评论