How to change UIWebView or WKWebView default font

前端 未结 9 1308
陌清茗
陌清茗 2020-12-08 01:14

What font does UIWebView and WKWebView use by default? I would like to be able to change that. But I don\'t want to do it in the html string, inste

9条回答
  •  孤街浪徒
    2020-12-08 01:52

    There is the swift 3 solution :

    func webViewDidFinishLoad(_ webView: UIWebView) {
        webView.stringByEvaluatingJavaScript(from: "document.getElementsByTagName('body')[0].style.fontFamily =\"-apple-system\"")
    }
    

    I have just put the default iOS font for this example

提交回复
热议问题