Label显示html文本

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

 

posted on 2017-05-26 15:15  Hauler  阅读(348)  评论(0编辑  收藏  举报

导航