Animation

Image Sequences

You have already used UIImageView to display an image, but it can also be used for displaying image sequences.

Header Source

View Animations

Most UIView properties can be animated, using class methods and blocks.

Let’s prepare an app for testing animations. First, create a custom UIView for drawing a target.

Header Source

Next, add this view to the center of your main view.

Next, add a gesture recognizer for double-tapping the main view.

You can now animate the target to the touch point using animateWithDuration:animations:

You can animate multiple views at the same time.

And you can add a completion handler, called when the animation is finished.

You can even nest other animations in the completion handler.

You can add a starting delay and set the easing function to your animation, using animateWithDuration:delay:options:animations:completion:

There are many different animation options. You combine them using the pipe | operator.

View Hierarchy Animations

You can animate transitions between views using transitionFromView:toView:duration:options:completion:

Comments are closed.