Ivaylo Nikolov Ivaylo Nikolov - 9 months ago 162
Swift Question

macOS WKWebView background transparency

If someone has experience with

, please share how to make the background of the view transparent. The
object has such option via
var drawsBackground: Bool { get set }
but it is missing for the
class. I searched the net and .. found nothing. Before time it was possible to do so via
property, but not anymore. There is a getter
... and that's it. I don't want to do it via CSS and already tried everything else, like:

webview.wantsLayer = true

webview.layer?.backgroundColor = NSColor.clear.cgColor

If someone can help ...

I. Nikolov

Ely Ely
Answer Source

This work for me, without deprecation warnings in macOS 10.12:

webView.setValue(false, forKey: "drawsBackground")