最近在做项目时 遇到服务端返回的数据是带有 html格式的文本 要按照这个格式显示
一时不知怎么办 经过查找资料 发现 NSAttributedString 是可以做到的 它支持HTML文本
具体的实现代码是
NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithData:[HTMLcontent dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];