Last active
April 12, 2019 05:45
-
-
Save erikolsson/baf954b0bae7fae629e5c413c26a8b9f to your computer and use it in GitHub Desktop.
This file contains 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
class AdjustableVisualEffectView: UIVisualEffectView { | |
private var animator: UIViewPropertyAnimator! | |
init(effect: UIVisualEffect?, intensity: CGFloat) { | |
super.init(effect: nil) | |
self.animator = UIViewPropertyAnimator(duration: 1, curve: .linear) { [weak self] in | |
self?.effect = effect | |
} | |
self.intensity = intensity | |
animator.fractionComplete = intensity | |
} | |
var intensity: CGFloat = 0 { | |
didSet { | |
animator.fractionComplete = intensity | |
} | |
} | |
required init?(coder aDecoder: NSCoder) { | |
fatalError() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment