Swift加载本地Html


letwebView =UIWebView.init()

webView.scrollView.bounces=false

webView.frame=self.view.bounds

self.view.addSubview(webView)

let path =Bundle.main.bundlePath

let url =URL.init(fileURLWithPath: path)

let htmlPath =Bundle.main.path(forResource:"protocol", ofType:"html")

let htmlContent =try!String.init(contentsOfFile: htmlPath!)

webView.loadHTMLString(htmlContent, baseURL: url)

你可能感兴趣的:(Swift加载本地Html)