Bronze Challenge: Spring Animations

iOS has a powerful physics engine built in. An easy way to harness this power is by using a spring animation.

// UIView

class func animate(withDuration duration: TimeInterval,
    delay: TimeInterval,
    usingSpringWithDamping dampingRatio: CGFloat,
    initialSpringVelocity velocity: CGFloat,
    options: UIViewAnimationOptions,
    animations: () -> Void,
    completion: ((Bool) -> Void)?)

Use this method to have the two labels animate on and off the screen in a spring-like fashion. Refer to the UIView documentation to understand each of the arguments.

Get iOS Programming: The Big Nerd Ranch Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.