UILabel展示HTML文本

来源:互联网 发布:js树状结构 编辑:程序博客网 时间:2024/04/25 18:18

NSString * htmlString = @” Some html string \n This is some text! “;
NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
UILabel * myLabel = [[UILabel alloc] initWithFrame:self.view.bounds];
myLabel.attributedText = attrStr;
[self.view addSubview:myLabel];

0 0
原创粉丝点击