str是要显示的HTML字符串,UILabel支持显示HTML显示
NSString *str = [timetable.content copy];
if(str.length>0){
NSMutableAttributedString *attrString =
[[NSMutableAttributedString alloc] initWithData:[str
dataUsingEncoding:NSUnicodeStringEncoding]
options:@{NSDocumentTypeDocumentAttribute:
NSHTMLTextDocumentType} documentAttributes:nil error:nil];
[attrString addAttribute:NSFontAttributeName value:[UIFont
systemFontOfSize:16] range:NSMakeRange(0, attrString.length)];
self.contentLabel.attributedText = attrString;
}