在使用Objective-C
Mac OSX
的{{1}}中,有没有办法让Cocoa
DIV
略微半透明,以便窗口后面的桌面应用程序略微流血,但仅限于WebView
,而不是DIV
的其余部分?
或许我可以让整个WebView半透明,但除了一个WebView
之外的所有DIV
都要关闭它?
我有DIV
加载网页。在网页中,我左侧有一个侧边栏,右侧有一个WebView
。我点击侧边栏上的项目,然后更改右侧的IFRAME
页面。我希望这个侧边栏略微半透明。
在我的IFRAME
中,到目前为止,我已将此AppDelegate.m
和HTML
标记设置为BODY
,并且我的侧边栏设置为background:none
但是我最终看到的只是一个灰色的侧边栏背景。就像webview本身想要确保它的背景设置为非透明颜色一样。
background:rgba(0,0,0,0.5)
答案 0 :(得分:2)
http://stylekit.org/blog/2016/01/23/Chromeless-window/
NSFullSizeContentViewWindowMask
(以便在标题栏区域中显示半透明效果,将其保留,标题栏区域将为空白)self.titlebarAppearsTransparent = true
(隐藏标题栏默认图片)
let visualEffectView = NSVisualEffectView(frame: NSMakeRect(0, 0, 0, 0))//<---the width and height is set to 0, as this doesn't matter.
visualEffectView.material = NSVisualEffectMaterial.AppearanceBased//Dark,MediumLight,PopOver,UltraDark,AppearanceBased,Titlebar,Menu
visualEffectView.blendingMode = NSVisualEffectBlendingMode.BehindWindow//I think if you set this to WithinWindow you get the effect safari has in its TitleBar. It should have an Opaque background behind it or else it will not work well
visualEffectView.state = NSVisualEffectState.Active//FollowsWindowActiveState,Inactive
self.contentView = visualEffectView/*you can also add the visualEffectView to the contentview, just add some width and height to the visualEffectView, you also need to flip the view if you like to work from TopLeft, do this through subclassing*/
答案 1 :(得分:1)
是的,只需将WebView
个实例的drawsBackground
属性设置为NO
,然后确保使用CSS填充您想要不透明的页面部分。