我需要将html文本转换为属性字符串。以下代码工作正常,但我更新了UITableViewCell
中的标签。因此,下面的代码花了很多时间转换为"属性字符串"。
NSAttributedString *attributedString = [[NSAttributedString alloc]
initWithData:[[stPhoto photoDetails] dataUsingEncoding:NSUnicodeStringEncoding]
options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil];
myLabel.attributedText = attributedString;
我尝试在dispatch_async
块中运行以下代码,但这并没有帮助。
还有其他方式吗?
我曾尝试使用DTCoreText
lib,但其安装过程很复杂,我不应该使用DTCoreText
框架来执行这么小的任务。
还有其他方法吗?
我的HTML文字可能包含以下内容: 粗体+斜体+ Underlin +子弹+文字颜色
请给我一些建议!!这真的很有帮助。
答案 0 :(得分:0)
我认为你有两个简单的选择