Here is the HTMLStringView
struct:
struct HTMLStringView: UIViewRepresentable {
let htmlContent: String
var webView: WKWebView = WKWebView()
func makeUIView(context: Context) -> WKWebView {
webView.scrollView.isScrollEnabled = false
return webView
}
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.loadHTMLString(htmlContent, baseURL: nil)
}
}
The WKWebView
cannot determine its frame size according to the html content inside. Maybe one could construct a function to determine the height according to the html content? Or, is there easier way to achieve this?