Cocoa NSView blurred background

家住魔仙堡 提交于 2019-12-06 09:45:06

In order to answer you, yes its Possible.

If you want that effect, check out this GitHub Project I created. I subclassed NSWindow in order to disable opacity and then I added a Background Filter:Gaussian Blur to the NSView using the View Effects Inspector located at the Xcode Utilities Side Bar (you can change the radius value for more or less blur effect).

If you want the new Yosemite View effect, check out the new class they released NSVisualEffectView, just subclass the NSView you want to use this effect.

Hope you find my answer useful.

Best regards,

pm200107

My contribution as I wanted to set the radius and the color.

Doing it in a custom view to blur what is behind. HTH

view.wantsLayer = true
view.layerUsesCoreImageFilters = true
view.layer?.backgroundColor = NSColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 0.5).CGColor

let blurFilter = CIFilter(name: "CIGaussianBlur")
blurFilter?.setDefaults()
blurFilter?.setValue(2.5, forKey: kCIInputRadiusKey)
view.layer?.backgroundFilters?.append(blurFilter!)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!