NSString * htmlString = @"<html><body>今天中午<font size=\"13\" color=\"red\">去哪吃什么</font><font size=\"5\" color=\"blue\">???</font> </body></html>";
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];UILabel用原生方法显示HTML文本
探讨HTML文本样式与标签应用
最新推荐文章于 2021-06-25 19:11:00 发布
本文详细解析了如何使用HTML进行文本样式设置,并通过标签应用展示了文本的不同表现形式。
1万+

被折叠的 条评论
为什么被折叠?



