Wave class provides a simple, block-based API for animating UIView and CALayer properties using physically-based spring animations.
Overview
Wave is the primary class you’ll use to create animations. It provides a static method that lets you animate view properties using spring physics, similar to UIKit’s animation APIs but with more natural, physically-based motion.
For animations to work correctly, you must set values on the view’s
animator property, not directly on the view itself. For example, use myView.animator.alpha = 1.0 instead of myView.alpha = 1.0.Methods
animate(withSpring:mode:delay:gestureVelocity:animations:completion:)
Performs animations based on theSpring value provided.
The
Spring used to determine the timing curve and duration of the animation. See Spring(dampingRatio:response:mass:) for more information on how to choose relevant spring values.Determines if the
animations block will be run with animation (default), or non-animatedly. See AnimationMode for information on when to use a non-animated mode.A delay, in seconds, after which to start the animation.
If provided, this value will be used to set the
velocity of whatever underlying animations run in the animations block. This should be primarily used to “inject” the velocity of a gesture recognizer (when the gesture ends) into the animations.A block containing the changes to your views’ animatable properties. Note that for animations to work correctly, you must set values on the view’s
animator, not just the view itself. For example, to animate a view’s alpha, use myView.animator.alpha = 1.0 instead of myView.alpha = 1.0.A block to be executed when the specified animations have either finished or retargeted to a new value. The first parameter indicates whether the animation finished, and the second indicates whether it was retargeted.