天天看點

利用UILabel、UITextView加載html文本

挺簡單,直接上代碼了

NSString *strHtml = @"<b>提示</b><br/>1、測試測試測試測試測試測試測試測試測試測試測試測試<br/>2、測試測試測試測試測試測試測試測試測試測試";
NSAttributedString * strAtt = [[NSAttributedString alloc] initWithData:[strHtml dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
self.labelContent.attributedText = strAtt;
self.textViewContent.attributedText = strAtt;