UILabel展示html文本
作者:
努力奔跑的小男孩 | 来源:发表于
2017-05-03 19:01 被阅读224次NSString * htmlString =@"<html><body> Some html string \n <font size=\"13\" color=\"red\">This is some text!</font> </body></html>";
NSAttributedString * attrStr = [[NSAttributedStringalloc] initWithData:[htmlStringdataUsingEncoding:NSUnicodeStringEncoding]options:@{ NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType } documentAttributes:nilerror:nil];
UILabel * myLabel = [[UILabelalloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; // 这里可以结合 自动布局(Masary),让label 自动扩充
myLabel.attributedText = attrStr;
[self.viewaddSubview:myLabel];
本文标题: UILabel展示html文本
本文链接:https://www.haomeiwen.com/subject/prdltxtx.html
网友评论