This demo app shows how to apply spring style animation to a button.
Animation is done by setting Scale
transform to the button inside animation block. This demo app allows to tweak duration
, damping
and velocity
parameters of the animation function.
button.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
UIView.animate(withDuration: 2.0,
delay: 0,
usingSpringWithDamping: 0.2,
initialSpringVelocity: 6.0,
options: .allowUserInteraction,
animations: { [weak self] in
self?.button.transform = .identity
},
completion: nil)
The Large Bubble Sound clip is taken from soundbible.com and recorded by snottyboy.