美文网首页
iOS label显示HTML富文本

iOS label显示HTML富文本

作者: 小码农CC | 来源:发表于2019-03-21 11:36 被阅读0次

NSString * htmlString = @" Some html string \nThis 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];

相关文章

网友评论

      本文标题:iOS label显示HTML富文本

      本文链接:https://www.haomeiwen.com/subject/pkjmuftx.html