如何显示htmlString到webview? html字符串包含引导图像

时间:2018-07-26 06:42:05

标签: ios swift webview

HTML字符串是:

<p> Business Name and City Located In <i class=\"fa fa-check\"></i></p>\r\n

1 个答案:

答案 0 :(得分:0)

let webview = UIWebView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))

let htmlString = "<p> Business Name and City Located In <i class=\"fa fa-check\"></i></p>\r\n"
let fontAwesomeHtml = """
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">\(htmlString)
"""
webview.loadHTMLString(fontAwesomeHtml, baseURL: nil)
view.addSubview(webview)

结果截图:

enter image description here