Animating a View on Your iOS App - dummies

By Neal Goldstein, Dave Wilson

Whenever you assign a new value to certain view properties (such as the frame and center properties), the view is immediately redrawn and the change is immediately visible on the screen.

In addition, changes to several view properties (such as those just mentioned) can be animated. This means that changing the property creates an animation that conveys the change to the user over a short period of time — and it’s all handled for you by the UIView class. What’s more, it takes only one method call to specify the animations to be performed and the options for the animation.

You can animate the following properties of the UIView class:

  • frame: This property contains the frame rectangle, which specifies the size and location of the view in its super view’s coordinate system.

  • bounds: This property contains the bounds rectangle, which specifies the size of the view (and its content origin) in the view’s own local coordinate system.

  • center: This property contains the known center point of the view in its super view’s coordinate system.

  • transform: Used to make a view rotation.

  • alpha: This property controls the degree of transparency. If you animate it, you can get views to fade in and fade out.

  • backgroundColor: This property allows you to transition from one color to another.

  • contentStretch: This property controls how a view’s content is stretched to fill its bounds when the view is resized and is often used to animate the resizing of buttons and controls.