O'Reilly logo

Mastering iOS 11 Programming - Second Edition by Donny Wals

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Refactoring existing animations with UIViewPropertyAnimator

So far, you have seen animations that were implemented using the UIView.animate method. These animations are quite simple to implement and mostly follow the following format:

UIView.animate(withDuration: 1.5, animations: {     myView.backgroundColor = UIColor.red() }) 

You have also seen this method implemented in other forms, including one that used a closure that was executed upon completion of the animation. For instance, when a user taps on one of the contacts in the HelloContacts app, the following code is used to animate a bounce effect:

UIView.animate(withDuration: 0.1, delay: 0, options: [.curveEaseOut], animations: { cell.contactImage.transform = CGAffineTransform(scaleX: 0.9, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required