Using custom font in a UIWebView

后端 未结 3 1669
不思量自难忘°
不思量自难忘° 2020-11-30 19:46

I would like to display a custom font inside a UIWebView. I have already put the font in the plist under \"Fonts provided by application\". The code in use:

         


        
3条回答
  •  离开以前
    2020-11-30 20:00

    For Swift and WKWebView, this worked for me:

    @IBOutlet weak var webView: WKWebView!
    
    
    let html = """
    
    
        
    
    
        My HTML Content
    
    
    """
    
    
    let baseURL = URL(fileURLWithPath: Bundle.main.bundlePath)
    webView.loadHTMLString(html, baseURL: baseURL)
    

提交回复
热议问题