Graphics Reference
In-Depth Information
the layer's frame is set to be a quarter
the size of the
contentView
and centered
onscreen.
NOTE
On the iPhone, the layer is already in place.
You need to override the class method
+layerClass
instead to control the layer
that is used.
In Interface Builder, add three buttons
to the window; one for each transform
that we perform: Scale, Rotate, and 3D
Rotate. The resulting window is shown
in Figure 5-1.
FIGURE 5-1
Interface Builder Window
The Scale button is bound to the method
-scaleTransform:
, implemented as shown in
Listing 5-2.
LISTING 5-2
-scaleTransform:
- (
IBAction
)scaleTransform:(
id
)sender
{
NSValue
*value =
nil
;
CABasicAnimation
*animation =
nil
;
CATransform3D
transform;
[[
self
workLayer
]
removeAllAnimations
];
animation = [CABasicAnimation animationWithKeyPath:
@”transform”
];
transform =
CATransform3DMakeScale
(0.5f, 0.5f, 1.0f);
value = [NSValue valueWithCATransform3D:transform];
[animation
setToValue
:value];
transform =
CATransform3DMakeScale
(1.0f, 1.0f, 1.0f);