美文网首页
在UITextView中显示html文本

在UITextView中显示html文本

作者: 然亦伞 | 来源:发表于2017-07-10 18:11 被阅读13次
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 30, 100, 199)];
    textView.backgroundColor = [UIColor redColor];
    [self.view addSubview:textView];
    NSString *htmlString = @"
![](http://blogs.babble.com/famecrawler/files/2010/11/mickey_mouse-1097.jpg)";
    NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData: [htmlString dataUsingEncoding:NSUnicodeStringEncoding] options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes: nil error: nil];
    textView.attributedText = attributedString;

相关文章

网友评论

      本文标题:在UITextView中显示html文本

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