Transforms

The iOS SDK includes affine transformations as part of its Core Graphics implementation. Affine transforms allow points in one coordinate system to transform into another coordinate system. These functions are widely used in both 2D and 3D animations. The version used with UIKit views uses a 3-by-3 matrix to define UIView transforms, making it a 2D-only solution. 3D transforms use a 4-by-4 matrix and are the default for Core Animation layers. With affine transforms, you can scale, translate, and rotate your views in real time. You do so by setting a view’s transform property. Here’s an example:

float angle = theta * (PI / 100.0); CGAffineTransform transform = CGAffineTransformMakeRotation(angle); myView.transform ...

Get The Core iOS Developer’s Cookbook, Fifth Edition 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.