小编Sco*_*t C的帖子

如何获得半透明模糊背景的窗口

我希望得到一个半透明模糊背景的窗口,就像终端可以做的那样.观看此视频,大约30秒,看看我的意思:http://www.youtube.com/watch?v = zo8KPRY6-Mk

请在此处查看图片:http://osxdaily.com/wp-content/uploads/2011/04/mac-os-x-lion-terminal.jpg

我一直在谷歌搜索一个小时,无法得到任何工作.我相信我需要以某种方式创建一个核心动画层并添加一个背景过滤器,但到目前为止我还没有成功......我只看到了窗口的灰色背景.这是我到目前为止的代码:

码:

//  Get the content view -- everything but the titlebar.
NSView *theView = [[self window] contentView];
[theView setAlphaValue:0.5];

// Create core animation layer, with filter
CALayer *backgroundLayer = [CALayer layer];
[theView setWantsLayer:YES];
[theView setLayer:backgroundLayer]; 
CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[blurFilter setDefaults];
[theView layer].backgroundFilters = [NSArray arrayWithObject:blurFilter];  
[[theView layer] setBackgroundFilters:[NSArray arrayWithObject:blurFilter]];
Run Code Online (Sandbox Code Playgroud)

有什么提示或例子可以做我想做的事情吗?谢谢!

macos cocoa calayer nswindow

7
推荐指数
1
解决办法
5408
查看次数

标签 统计

calayer ×1

cocoa ×1

macos ×1

nswindow ×1