How do we get the height value of HTML content from UIViewRepresentable?
I want to get a height value from the HTML content that I have loaded to WebKit, How do I get that?
this is my code.
struct HTMLView: UIViewRepresentable {
let htmlContent: String
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
let anuphanRegular = getDataString(otf: "Anuphan-Regular")
let htmlString = """
<!doctype html>
<meta charset="utf-8"/>
<html>
<head>
<style>
@font-face {
font-family: 'Anuphan';
src: url('data:font/otf;base64,\(anuphanRegular)') format('opentype');
}
</style>
</head>
<body>
<div class="container">
<div class="element">
<span class="custom">\(htmlContent)</span>
</div>
</div>
</body>
</html>
"""
uiView.loadHTMLString(htmlString, baseURL: nil)
}
}