在工程根目录建立一个文件夹,然后拖到Xcode, 注意要选蓝色文件夹
let htmlName = "html_name"
let htmlType = "html"
private func loadHtml() {
let filePath = Bundle.main.path(forResource: htmlName, ofType: "html")!
do {
let html = try String(contentsOfFile: filePath, encoding: String.Encoding.utf8)
webView.loadHTMLString(html, baseURL: Bundle.main.resourceURL)
} catch {
}
}
网友评论