You can use the NSTimer class to simulate a simple animation by continuously changing the position of the Image View, but you can also use the transformation techniques supported by the iOS SDK to achieve the same effect.

Transforms are defined in Core Graphics (a C-based API that is based on the Quartz advanced drawing engine; you use this framework to handle things such as drawings, transformations, image creation, etc.), and the iOS SDK supports standard affine 2D transforms. You can use the iOS SDK to perform the following affine 2D transforms:

  • Translation — Moves the origin of the view by the amount specified using the x and y axes
  • Rotation — Moves the view by the angle specified
  • Scaling — Changes the scale of the view by the x and y factors specified

image NOTE An affine transformation is a linear transformation that preserves co-linearity and ratio of distances. This means that all the points lying on a line initially will remain in a line after the transformation, with the respective distance ratios between them maintained.

Figure 13-7 shows the effects of the various transformations.


To perform an affine transform on a view, simply use its transform property. Recall that in the previous example, you set the new position of the view through its center property: = CGPointMake( + delta.x, + ...

Get Beginning iOS 5 Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.