if (self.messageModel) {
NSString * htmlString = self.messageModel.contentText;
NSAttributedString * attrStr1 = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil]; //就这句有用
self.messageTextView.attributedText = attrStr1;
if (1) {
NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:@"【重要】"];
[attrStr appendAttributedString:attrStr1];
NSRange range = NSMakeRange(0, 4);
[attrStr addAttribute:NSForegroundColorAttributeName value:GNHGreenColor range:range];
self.messageTextView.attributedText = attrStr;
}
}
显示如下:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)