UILabel顯示html文本

NSString * htmlString = @"<html><body> Some html string \n <font size=\"13\" color=\"red\">This is some text!</font> </body></html>";  html

NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil]; code

UILabel * myLabel = [[UILabel alloc] initWithFrame:self.view.bounds];  htm

myLabel.attributedText = attrStr;  string

[self.view addSubview:myLabel]; it

相關文章
相關標籤/搜索