Created
February 22, 2018 18:02
-
-
Save mansi-27/fae60895c6b15921a7efdf382c4f2bf4 to your computer and use it in GitHub Desktop.
Produce fade-in fade-out animation based on view's alpha
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
| extension UIView { | |
| /// Produce fade in animation | |
| func fadeIn(_ duration: TimeInterval = 1.0, delay: TimeInterval = 0.0, completion: @escaping ((Bool) -> Void) = {(finished: Bool) -> Void in}) { | |
| UIView.animate(withDuration: duration, delay: delay, options: UIViewAnimationOptions.curveEaseIn, animations: { | |
| self.alpha = 1.0 | |
| }, completion: completion) | |
| } | |
| /// Produce fadeout animation | |
| func fadeOut(_ duration: TimeInterval = 1.0, delay: TimeInterval = 0.0, completion: @escaping (Bool) -> Void = {(finished: Bool) -> Void in}) { | |
| UIView.animate(withDuration: duration, delay: delay, options: UIViewAnimationOptions.curveEaseIn, animations: { | |
| self.alpha = 0.0 | |
| }, completion: completion) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment