我希望能够在网格和列表模式下复制dock Stacks的背景。背景是半透明黑色,具有模糊效果:
网格模式下dock stack示例http://www.thecustommac.com/wp-content/uploads/2009/09/stack-highlight.jpg
问题是[CALayer backgroundFilters]仅适用于窗口中的内容,过滤器不适用于其他窗口中的内容。这是我的代码:
我想不出其他实现这种效果的方法。(我查看了显示服务,看看是否有任何有用的功能,但我没有看到任何。) 有什么想法吗?
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
//make window transparent
self.window.backgroundColor = [NSColor clearColor];
[self.window setOpaque:NO];
[self.window setHasShadow:NO];
[self.window setStyleMask:NSBorderlessWindowMask];
//make the content view layer hosting
CALayer *rootLayer = [CALayer layer];
[[self.window contentView] setLayer:rootLayer];
[[self.window contentView] setWantsLayer:YES];
//blur the background contents - NOT WORKING!
[rootLayer setBackgroundColor:CGColorCreateGenericGray(0.0, .716)];
CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[blurFilter setDefaults];
[rootLayer setBackgroundFilters:[NSArray arrayWithObject: blurFilter]];
}
我想不出其他实现这种效果的方法。(我查看了显示服务,看看是否有任何有用的功能,但我没有看到任何。) 有什么想法吗?