Im a new in IOS. And i want to change font in WebView.
My webView page loading like this:
// contentRendered - cames from API like html
self?.webView.loadHTMLString(contentRendered, baseURL: nil)
I have code for change font:
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
let font = UIFont.init(name: "Quicksand-Regular", size: 22)
let jsFont = "document.getElementsByTagName('body')[0].style.fontFamily = '\(font!)';"
webView.evaluateJavaScript(jsFont, completionHandler: nil)
}
But it doesnt work. Quicksand-Regular
i have in resources folder
UPD:
let jsFont = "document.getElementsByTagName('body')[0].style.fontFamily = 'Quicksand-Regular';"
webView.evaluateJavaScript(jsFont, completionHandler: nil)
Doesnt work too
Text p
,Title
` there may be a problem due to the fact that the text does not contain the full html tags(body, etc)? – xivosij786 Jul 08 '21 at 09:26