美文网首页
iOS UIlabel识别html标签

iOS UIlabel识别html标签

作者: 放开那个小卤蛋 | 来源:发表于2016-02-04 14:11 被阅读2260次

NSString * htmlString = @" html代码";

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 UIlabel识别html标签

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