Layer Transformations

Layer Kit's rendering capabilities allow a 2-D image to be freely manipulated as if it were 3-D. An image can be rotated on an X-Y-Z axis to any angle, scaled, and skewed. The LKTransform object is the magic behind Apple's Cover Flow® technology. The Apple desktop uses the Core Animation framework to process 3-D transformations. The iPhone's Layer Kit framework uses many of the same functions, but has renamed them with the prefix LK (Layer Kit) instead of CA (Core Animation). The iPhone supports scale, rotation, affine, and translation transformations. More information about these various transformations can be found in Apple's Core Animation Programming Guide available on the Apple Developer Connection web site.

A transformation is carried out on the level of individual layers. The Layer Kit framework performs transformations using an LKTransform object. This object is applied to a view's layer to bend or otherwise manipulate its layer into the desired 3-D configuration. The application continues to treat the object as if it's a 2-D object, but when it is presented to the user, the object conforms to whatever transformation has been applied to the layer. The following example creates a transformation for the purpose of rotating a layer.

LKTransform myTransform;
myTransform = LKTransformMakeRotation(angle, x, y, z);

The LKTransformMakeRotation method creates a transformation that will rotate a layer by angle radians using an axis of X-Y-Z. The values for X-Y-Z ...

Get iPhone Open 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.