一. 修改NSString字符串中某段字符串的颜色
NSMutableAttributedString *totalContentAttributedStr = [[NSMutableAttributedString alloc] initWithString: resultStr];
UIColor *highLightColor = COLOR_RED;
[totalContentAttributedStr setAttributes:@{NSForegroundColorAttributeName : highLightColor, NSFontAttributeName : [AdaptiveClass ultimateEditionBySize:17 isBlod:NO]} range:NSMakeRange(firstItemStr.length, keyStr.length)];
self.contentLabel.attributedText = totalContentAttributedStr;
NSAttributedString,NSMutableAttributedString是带属性的特殊字符串,NSMutableParagraphStyle是带属性的文本段落属性,用于控制段落有关属性
**1、NSAttributedString **
参考
网友评论