(IOS)在UITextView中显示html文本

UITextView*textView = [[UITextViewalloc]initWithFrame:CGRectMake(20,30,100,199)];

textView.backgroundColor = [UIColor redColor];

[self.view addSubview:textView];

NSString *htmlString = @"

header

Subheader

Sometext

![](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;

你可能感兴趣的:((IOS)在UITextView中显示html文本)