// 首先去掉 UIVisualEffectView 原來(lái)的 effect摊鸡。
self.effectView.effect = nil
// 現(xiàn)在動(dòng)畫(huà)添加一個(gè)新的 effect贡羔。
let blurEffect = UIBlurEffect(style: .Light)
UIView.animateWithDuration(1.5, delay: 0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0, options: .CurveEaseOut, animations: {
self.effectView.effect = blurEffect
}) { _ in }
// 設(shè)置 view 的背景顏色(其實(shí)就是設(shè)置背景視圖)
self.view.backgroundColor = UIColor(patternImage: UIImage(named: "Snip20160725_3")!)
// 效果視圖(效果為模糊)
let effectView = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight))
effectView.frame = CGRect(x: 10, y: 100, width: 300, height: 100)
// 設(shè)置透明度
effectView.alpha = 0.5
view.addSubview(effectView)