美文网首页
UILabel 显示 html

UILabel 显示 html

作者: Yang152412 | 来源:发表于2018-03-08 15:09 被阅读130次

目前项目中遇到需要把带有html标签的文本显示出来,之前用的是UILabel控件 所有直接使用

  NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[contentString  dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSFontAttributeName:[UIFont systemFontOfSize:25.0f] } documentAttributes:nil error:nil];
_contentLabel.attributedText = attrStr;//用于显示

注:发现已经设置了字体大小但是还是不能改变,就把之前创建label时候设置的字体大小放在此行代码下面就改变大小了。

转载http://blog.csdn.net/pyf_1993/article/details/52153876

相关文章

网友评论

      本文标题:UILabel 显示 html

      本文链接:https://www.haomeiwen.com/subject/fmdyfftx.html