当前位置:Gxlcms > html代码 > UILabel用原生方法显示HTML文本_html/css_WEB-ITnose

UILabel用原生方法显示HTML文本_html/css_WEB-ITnose

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

NSString * htmlString = @"今天中午去哪吃什么??? ";    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];

人气教程排行