OS X开发-添加模糊效果
2015-07-31 本文已影响157人
lfb_CD
func setbulrEffct(){
var blurView = NSView(frame: self.view.bounds)
blurView.wantsLayer = true
blurView.layer?.backgroundColor = NSColor.clearColor().CGColor
blurView.layer?.masksToBounds = true
blurView.layerUsesCoreImageFilters = true
blurView.layer?.needsDisplayOnBoundsChange = true
var satFilter = CIFilter(name: "CIColorControls")
satFilter.setDefaults()
satFilter.setValue(NSNumber(float: 2.0), forKey: "inputSaturation")
var blurFilter = CIFilter(name: "CIGaussianBlur")
blurFilter.setDefaults()
blurFilter.setValue(NSNumber(float: 1.0), forKey: "inputRadius")
blurView.layer?.backgroundFilters = [satFilter, blurFilter]
self.view.addSubview(blurView)
blurView.layer?.needsDisplay()
}