UILabel 富文本功能

用到的是 Ios的富文本功能

NSString  * htmlString = @" Some html string \n This is some text!";
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];
富文本.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,262评论 4 61
  • 世上那么多男男女女,他们她们在高楼大厦,钢筋水泥之间,还是楼台水榭,青石板路,小桥流水,还是穷山恶水,山间小道,...
    走吧cqj阅读 242评论 0 0
  • 【专题:茶香】 其实真正台湾高山乌龙茶,台湾有九成茶人喝,自己喝都不够,政府也限制出口。因此,大陆不可能有台湾高山...
    南阳雅月阅读 2,974评论 14 3