程序员人生 网站导航

UILabel用原生方法显示HTML文本

栏目:综合技术时间:2015-05-22 08:43:25
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];


------分隔线----------------------------
------分隔线----------------------------

最新技术推荐