Last active
February 20, 2021 18:37
-
-
Save budidino/af1edcb204bcf94874680e1a1b125461 to your computer and use it in GitHub Desktop.
Useful UIView extensions for animating views - usually used when UIView is updated or interacted with
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 { | |
func springIn(duration: TimeInterval = 0.5, delay: Double = 0, fromScale: CGFloat = 0.6) { | |
self.layer.removeAllAnimations() | |
self.alpha = 1 | |
self.transform = CGAffineTransform(scaleX: fromScale, y: fromScale) | |
UIView.animate(withDuration: duration, delay: delay, usingSpringWithDamping: 0.5, initialSpringVelocity: 3.0, options: [.curveEaseInOut, .allowUserInteraction], animations: { | |
self.transform = .identity | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment