V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
daiyuechuan
V2EX  ›  问与答

除了 WebView 还有其他方式在页面上显示 HTML 内容吗?

  •  
  •   daiyuechuan · 2015-04-10 08:39:02 +08:00 · 3017 次点击
    这是一个创建于 3302 天前的主题,其中的信息可能已经有所发展或是发生改变。

    想问下除了用WebView,还有没有其他的方式在View里显示HTML的内容,比如一篇从数据库读取出来的带有HTML标签的文章。

    3 条回复    2015-04-10 09:34:10 +08:00
    yopming
        1
    yopming  
       2015-04-10 09:17:59 +08:00   ❤️ 1
    HTML不知道
    但是如果是文章的话,可以参考Flipboard,使用canvas来渲染文章

    https://github.com/Flipboard/react-canvas
    React Canvas brings some of the APIs web developers are familiar with and blends them with a high performance drawing engine.
    jtn007
        2
    jtn007  
       2015-04-10 09:29:17 +08:00
    使用NSAttributedString创建html字符串?
    好久不搞IOS了,不是很确定
    https://gist.github.com/Neo-J/d42f5c2a03d257eba3bf
    blank_dlh
        3
    blank_dlh  
       2015-04-10 09:34:10 +08:00   ❤️ 1
    iOS 中可以自己解析 HTML 为 NSAttributedString,然后直接丢给 UILabel 处理就好了;
    iOS 7 以后,提供了现成的方法来从 HTML 转换为 NSAttributedString,支持一些简单的样式;
    如果比较复杂,比如图文混排什么的,只能自己解析完,自己用 Core Text 绘制。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5822 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 03:00 · PVG 11:00 · LAX 20:00 · JFK 23:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.