UILabel加載html文本
NSString * htmlString = @"<html><body> Some html string \n <font size=\"13\" color=\"red\">This is some text!</font> </body></html>";
NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
UILabel * myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 200, 50)];
myLabel.attributedText = attrStr;
myLabel.backgroundColor = [UIColor greenColor];
[self.view addSubview:myLabel];
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者