A quick look at UIViewPropertyAnimator

Yesterday, the first day of WWDC, was full of exciting improvements to all of Apple’s platforms. For me, the most impressive update of all was to animations in UIKit. Meet the brand new UIViewPropertyAnimator.

Until iOS10, performing gesture-based and interruptible animations on iOS was a pain — often requiring a third party framework. Facebook’s POP was created for this very purpose and my most recent open source project, Interpolate, tried to tackle the same problem.

It’s great to see this kind of functionality finally built into UIKit and I’m sure it will allow for many more ‘magical’ apps on iOS.

How does it work?

Animations are essentially interpolations between UIView properties that you define in a closure. You can either let an animation run with a duration or you can connect a gesture to update the animator’s fractionComplete property. All the animations are easily interruptible and reversible by default.

Here’s a simple example:

To go deeper, check out the docs: