Less Blur with `Visual Effect View with Blur`?

后端 未结 11 1329
死守一世寂寞
死守一世寂寞 2020-12-08 10:11

Title pretty much asks it all...

I\'m playing with the iOS8 Visual Effect View with Blur. It\'s over a UIImageView that shows a user choosa

11条回答
  •  孤街浪徒
    2020-12-08 10:46

    Similar to @mitja13's solution, but uses UIViewPropertyAnimator, slightly more succinct:

    var animator: UIViewPropertyAnimator!
    
    viewDidLoad() {
       super.viewDidLoad()
    
       let blurEffectView = UIVisualEffectView()
       yourViewToBeBlurred.addSubview(blurEffectView)
       blurEffectView.fillSuperview() // This my custom method that anchors to the superview using auto layout. Write your own
    
       animator = UIViewPropertyAnimator(duration: 1, curve: .linear, animations: {
           blurEffectView.effect = UIBlurEffect(style: .regular)
       })
    
       animator.fractionComplete = 0.6 // Adjust to the level of blur you want
     
    }
    

提交回复
热议问题