【问题标题】:How to change the line spacing of the text in UIWebView in Swift如何在 Swift 中更改 UIWebView 中文本的行距
【发布时间】:2017-08-16 21:01:24
【问题描述】:

我有一个UIWebView,里面有一段特定的段落。我想设置该段落的行之间的行距。谁能帮我解决这个...?

提前谢谢..

【问题讨论】:

  • 你是在 webview 还是 weburl 中加载 html 字符串?
  • 我正在加载一个 html 字符串...
  • 检查这是否有帮助:stackoverflow.com/questions/14359339/… 您需要在您身边附加元素或在您获得的 html 字符串中进行更改。
  • 您可以随时加载 <style>*Your css for line spacing*</style> 并在其末尾附加您的 html 字符串以“注入”css 到UIWebView
  • @D.M 请检查我的回答

标签: ios swift uiwebview spacing


【解决方案1】:

您必须通过调用此代码将用于行距的 javascript 代码添加到 UIWebView's 源代码中

func stringByEvaluatingJavaScript(from script: String) -> String?

For Example:
        let JSString = //A javascript code for line spacing
        webview.stringByEvaluatingJavaScript(from:JSString)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-06
    • 1970-01-01
    • 2013-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多