Graphics Reference
In-Depth Information
FIGURE 5-3
Lower Left Anchor Point
Combining Transforms
So far, we have covered single transforms, either rotating or scaling the layer. But what if
you want to perform more than one transform at the same time? Fortunately for you,
we're about to show you how.
To demonstrate how to combine transformations, we do a slightly different project. We
start with a standard Cocoa application from the Xcode template and add an
AppDelegate . The AppDelegate retains a reference to the NSWindow so that it can be
manipulated. Then, within the -applicationDidFinsihLaunching: method, we set up the
layers, as shown in Listing 5-6.
LISTING 5-6
applicationDidFinishLaunching
- ( void )applicationDidFinishLaunching:( NSNotification *)notification
{
CGColorRef color;
NSView *contentView = [[ self window ] contentView ];
CALayer *rootLayer = [ CALayer layer ];
color = CGColorCreateGenericRGB (0.0, 0.0, 0.0, 1.0);
[rootLayer setBackgroundColor :color];
[contentView setLayer :rootLayer];
[contentView setWantsLayer : YES ];
layer = [CALayer layer];
color = CGColorCreateGenericRGB (0.5f, 0.5f, 0.5f, 1.0f);
 
Search WWH ::




Custom Search