透明背景 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屋!