我爱编程

模糊效果

2018-03-29  本文已影响15人  流年易逝_李

        // 首先创建一个模糊效果

        let blurEffect =UIBlurEffect(style: .dark)

        // 接着创建一个承载模糊效果的视图

        let blurView =UIVisualEffectView(effect: blurEffect)

        // 设置模糊视图的大小(全屏)

        blurView.frame.size = CGSize(width: view.frame.width, height: view.frame.height)

        // 创建并添加vibrancy视图

        let vibrancyView =UIVisualEffectView.init(effect:UIVibrancyEffect.init(blurEffect: blurEffect))

        vibrancyView.frame.size=CGSize(width:view.frame.width, height:view.frame.height)

        blurView.contentView.addSubview(vibrancyView)

        self.view.addSubview(blurView)

上一篇 下一篇

猜你喜欢

热点阅读