I have a WKWebView
in my view
@IBOutlet weak var htmlWKWebView: WKWebView!
I want to change background color to red. I tried:
htmlWKWebView.wantsLayer = true
htmlWKWebView.layer?.masksToBounds = true
htmlWKWebView.layer?.isOpaque = false
htmlWKWebView.layer?.backgroundColor = NSColor.red.cgColor
Nothing worked. Only this:
htmlWKWebView.setValue(false, forKey: "drawsBackground")
made background transparent. But background color not set
How about using webView.setValue(false, forKey: "drawsBackground")
and set color on the view underneath the webview? Use something like: bgColorView.setValue(myBGColor, forKey: "backgroundColor")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With