我目前正在使用 Core Text 显示一些文本。但是我发现 Core Text 不支持未格式化的 html 字符串。所以如果有任何库可以格式化一段 html 字符串?谢谢。
最佳答案
我用过 Cocoanetics DTCoreText为此,效果很好。
NSString *path = [[NSBundle mainBundle] pathForResource:@"AboutMonkeys" ofType:@"html"];
NSData *data = [NSData dataWithContentsOfFile:path];
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL];
self.attributedTextView.attributedString = attributedString;
self.attributedTextView.contentInset = UIEdgeInsetsMake(10, 10, 10, 10);
Here is an article进一步讨论这个问题
关于html - 用于格式化 html 的 iOS 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22268551/