Skip to content

Instantly share code, notes, and snippets.

@budidino
Last active Feb 20, 2021
Embed
What would you like to do?
Useful UIView extensions for animating views - usually used when UIView is updated or interacted with
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