我需要渲染文本,但不在 UIWebView 中
我已经查了很多,但找不到好的文本渲染解决方案。就我而言, uiwebview 不能满足我的需求。此外,文本必须使用多种字体。我希望它像 iBooks 中一样,文本渲染速度非常快(不像 uiwebview 中的那样)或者可能是 uiwebview,但是他们如何做到快速加载呢?
文本还应该支持文本选择和其他用户交互。
我愿意接受建议,提前致谢!
I've looked quite a lot but can't find a good text rendering solution. In my case uiwebview doesn't fullfil my needs. Also the text has to be with multiple fonts. I would like it to be like in iBooks, the text renders very fast(not like in the uiwebview) or maybe it's uiwebview, but then how do they do it to load that fast?
The text should also support text selection and other user interactions.
I'm open for suggestions, thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以查看 NSAttributedString-Additions-for-HTML,它会创建 < code>NSAttributedString 来自 HTML,并位于 TTTAttributedLabel (或 OHAttributedLabel),支持
NSAttributedStrings
UILabel 的直接替代品代码>.You can have a look at NSAttributedString-Additions-for-HTML, it creates
NSAttributedString
from HTML, and at TTTAttributedLabel (or OHAttributedLabel), a drop-in replacement forUILabel
that supportsNSAttributedStrings
.听起来你应该看看 核心文本< /a>.它是专门用于文本渲染的框架。
It sounds like you should look at Core Text. It is framework intended specifically for text rendering.
您应该看看 Core Text 框架。仅用于某些文本行可能有点复杂,但它可能正是您正在寻找的。
这是苹果官方文档:
Core Text Framework Apple 官方文档
对于初学者来说,这是一个很好的链接:
交友核心文本
You should have a look at the Core Text framework. It can be a bit complicated to use just for some lines of text, but it may be what you are looking for.
Here is the Apple official documentation :
Core Text Framework Apple official documentation
And here is a good link for beginners :
Befriending Core Text
文本选择和用户与 CoreText 的交互并不是那么简单。
据我所知,支持文本选择的最好的开源库是 OmniGroup。
查看他们的 TextEditor 示例,了解与您要求的类似的内容。
Text selection and user interaction with CoreText is not so simple.
The best open source library that I know of that supports text selection is OmniGroup.
Look at their TextEditor example for something similar to what you requested.