OS X开发-添加模糊效果

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()
    }

你可能感兴趣的:(OS X开发-添加模糊效果)