我要複製碼頭堆棧的背景網格和列表模式。背景是半透明的黑色模糊效果:套用CIFilter背景過濾器時,主窗口是透明
的問題是,[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]];
}
我想不出如何實現這種效果。 (我看了顯示服務,看看是否有任何有用的功能,但我看不到任何。)
任何想法?
神奇,非常感謝你! – 2010-07-21 14:07:41
FWIW,這不再顯示在優勝美地工作。 :-(CGSNewCIFilterByName()返回kCGErrorNotImplemented。 – 2014-10-25 03:26:20