首页 > Web开发 > 详细

Label显示html文本

时间:2017-05-26 15:47:41      阅读:347      评论:0      收藏:0      [点我收藏+]
    NSString * htmlString = @"<p>主要原料:葛根提取物、杜仲叶提取物、天麻提取物</p><p>功效成分:100g含:葛根素4.8g</p><p>保健功能:辅助降血压</p><p>食用方法:每日3次,每次2粒,口服。</p><p>适宜人群:血压偏高者</p><p>不适宜人群:少年儿童、孕妇、乳母。</p><p>净含量: 0.35g/粒×90粒/瓶</p><p>批准文号:国食健字G20130523</p><p>注意事项:本品不能代替药品</p><p>统一售价:¥380</p><p></p>";
    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
    UILabel * testLabel = [[UILabel alloc] initWithFrame:self.view.bounds];
    testLabel.numberOfLines = 0;
    testLabel.attributedText = attrStr;
    [self.view addSubview:testLabel];
    

 

Label显示html文本

原文:http://www.cnblogs.com/hauler/p/6908651.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!