html - 用于格式化 html 的 iOS 库

标签 html ios core-text

我目前正在使用 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/

相关文章:

ios - DT AttributedText ContentView 绘制边框

html - 如何在没有偏移的情况下在 HTML/CSS 中集成文本

html - Box-Shadow :before,:在 z-index 堆叠问题之后

ios - NSMutableAttributedString 不起作用

ios - 如何用弹出窗口样式显示 UISplitViewController 的主视图?

ios - 如何在iOS的NSAttributedString中设置属性?

ios - 如何在MonoTouch中使用CoreText编写旋转文本?

Javascript 使用 for 循环和数组列表

javascript - Jquery bxslider 不工作 + Angular js ng-repeat 问题

ios - CGAffineTransform 动画没有在正确的位置结束