当前位置:Gxlcms > html代码 > UILabel可以显示html文本_html/css_WEB-ITnose

UILabel可以显示html文本_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:70人阅读

NSString * htmlString = @" Some html string \n This is some text! ”;

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];

人气教程排行