如何使一部分Web视图略微半透明? [英] How To Make Part of Web View Slightly Translucent?
问题描述
Objective-C
与 Mac OSX
Cocoa
,是否有任何方法使 DIV
在 WebView
稍微半透明,以便窗口后面的桌面应用程序泄漏稍微,但只有 DIV
,而不是 WebView
的其余部分
In Objective-C
with Mac OSX
Cocoa
, is there any way to make a DIV
on a WebView
slightly translucent so that the desktop applications behind the window bleed through slightly, but only on that DIV
and not the rest of the WebView
?
或者我可以让整个WebView半透明,但关闭所有 DIV
,除了一个 DIV
?
Or perhaps I can make the whole WebView translucent, but turn it off for all DIV
s except one DIV
?
我有一个 WebView
加载网页。在网页中,我有一个侧边栏在左边,然后一个 IFRAME
在右边。我单击侧栏上的项目,他们更改了右侧的 IFRAME
页面。
I have a WebView
loading a web page. In the web page, I have a sidebar on the left, and then an IFRAME
on the right. I click items on the sidebar and they change the IFRAME
pages on the right. It's this sidebar that I want to make slightly translucent.
在我的 AppDelegate.m
中,我有这个,我的 HTML
和 BODY
标记设置为 background:none
,我的侧边栏设置为 background:rgba(0,0,0,0.5)
,但我最后看到的是一个灰色边栏背景。这就像webview本身想要确保它的背景设置为一个不同于清晰的颜色。
In my AppDelegate.m
, I have this so far, and my HTML
and BODY
tags are set to background:none
, and my sidebar is set to background:rgba(0,0,0,0.5)
, but all I end up seeing is a grey sidebar background. It's like the webview itself wants to ensure that it's background is set to a color other than clear.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// note that _window and _wv are outlet properties to my window and webview widgets
[_window setBackgroundColor:[NSColor clearColor]];
[_window setOpaque:NO];
[_wv.layer setBackgroundColor:[NSColor clearColor].CGColor];
[_wv.layer setOpaque:NO];
}
推荐答案
a href =https://developer.apple.com/library/mac/documentation/Cocoa/Reference/WebKit/Classes/WebView_Class/#//apple_ref/occ/instp/WebView/drawsBackground =nofollow> 实例到
NO
的 drawsBackground
,然后确保使用CSS填充您想要不透明的页面的部分。
Yes, just set the drawsBackground
property of your WebView
instance to NO
, then make sure to fill the parts of the page you want opaque using CSS.
这篇关于如何使一部分Web视图略微半透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!