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
A solution similar to some here, but simpler, is to use a UIViewPropertyAnimator (iOS 10+) and set its fractionComplete
property to some value between 0 and 1.
// add blur view to image view
let imgBlur = UIVisualEffectView()
imgView.addSubview(imgBlur)
imgBlur.frame = imgView.bounds
// create animator to control blur strength
let imgBlurAnimator = UIViewPropertyAnimator()
imgBlurAnimator.addAnimations {
imgBlur.effect = UIBlurEffect(style: .dark)
}
// 50% blur
imgBlurAnimator.fractionComplete = 0.5
Note, if you plan to vary fractionComplete
based on a pan gesture, scroll view, slider, etc. you'll want to set pausesOnCompletion = true
(iOS 11+).