This sample app showcase how to use the awesome UIViewPropertyAnimator to drive interactive animations. The UIViewPropertyAnimator can be started, paused, stopped, and manually progressed.
A few things to note about UIViewPropertyAnimator:
- How to use gesture velocity together with spring timing parameters.
- Having multiple active/running UIViewPropertyAnimators animating the same properties on the same UIView might cause unknown/unwanted behaviour. Therefore - if possible - either try group animations together in the same UIViewPropertyAnimator or create new animators when animating each animation (and throw away the old UIViewPropertyAnimator).
- The same can happen if having multiple animators with different timing parameters. A way to handle this might be to use UIViewPropertyAnimator together with keyframe-base animations. You can do that by calling UIView.animateKeyframes(withDuration:delay:options:animations:completion:), where the duration is set to 0 to inherit the timing parameters from the UIViewPropertyAnimator.
- I recommend checking out this awesome WWDC 2017 session on Advanced Animations with UIKit.