Last active
December 28, 2018 12:54
-
-
Save lanserxt/ad0e4eb4c8aedda8f228730f4625ec00 to your computer and use it in GitHub Desktop.
Blur animator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate var propertyAnimator: UIViewPropertyAnimator! | |
fileprivate var blurEffectView: UIVisualEffectView! | |
fileprivate var backGradientView: UIView! | |
func addWorkoutBlur() { | |
if !UIAccessibilityIsReduceTransparencyEnabled() { | |
if blurEffectView != nil { | |
blurEffectView.removeFromSuperview() | |
} | |
if backGradientView != nil { | |
backGradientView.removeFromSuperview() | |
} | |
if propertyAnimator != nil { | |
propertyAnimator.stopAnimation(true) | |
} | |
backGradientView = UIView(frame: self.bounds) | |
backGradientView.backgroundColor = UIColor.init(hexString: "#dae1e3")?.withAlphaComponent(0.7) | |
self.cornerView.addSubview(backGradientView) | |
let blurEffect = UIBlurEffect(style: .regular) | |
blurEffectView = UIVisualEffectView(effect: blurEffect) | |
blurEffectView.frame = self.bounds | |
self.foreImageView.addSubview(blurEffectView) | |
propertyAnimator = UIViewPropertyAnimator.init(duration: 3.0, curve: .linear) {[weak self] in | |
self?.blurEffectView.effect = nil | |
} | |
propertyAnimator.fractionComplete = 0.7 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment