透明背景WKWebView(NSView) [英] Transparent background WKWebView (NSView)
问题描述
我正在使用Swift构建Mac应用程序.因此,我想使WKWebView透明,以便它显示已加载的HTML的文本,但是底层NSWindow的背景是可见的. 我尝试过
webView.layer?.backgroundColor = NSColor.clearColor().CGColor;
没有任何效果. WKWebView继承自NSView,但我不知道这是否有帮助.
另一种解决方案是将NSVisualEffectView插入WebView的背景,但是我也不知道该怎么做!
不支持它,然后他们对其进行了修复:
https://bugs.webkit.org/show_bug.cgi?id=134779 >
使其透明的方法是:
myWebView.opaque = false
I am building a Mac application using Swift. Therefor, I want to make a WKWebView transparent, so it shows the text of the loaded HTML, but the background of my underlaying NSWindow is visible. I tried
webView.layer?.backgroundColor = NSColor.clearColor().CGColor;
which hadn't any effect. WKWebView inherits from NSView, but I don't know if this helps.
Another solution would be to insert a NSVisualEffectView as the background of the WebView, but I don't know how to accomplish that, either!
It was not supported, then they fixed it:
https://bugs.webkit.org/show_bug.cgi?id=134779
The way to make it transparent is to:
myWebView.opaque = false
这篇关于透明背景WKWebView(NSView)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!