美文网首页
OS X开发-添加模糊效果

OS X开发-添加模糊效果

作者: lfb_CD | 来源:发表于2015-07-31 12:17 被阅读157次
    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开发-添加模糊效果

          本文链接:https://www.haomeiwen.com/subject/aaxvqttx.html