Graphics Reference
In-Depth Information
LISTING 6-13
Continued
// Cause the layer to use its default transition
return nil ;
}
@end
The new RippleLayer class is used in the application's delegate class. The complete
AppDelegate code is in Listing 6-14.
LISTING 6-14
AppDelegate Implementation Using Encapsulation
#import “RippleLayer.h”
@interface AppDelegate : NSObject {
IBOutlet NSWindow *window;
RippleLayer *transitionLayer;
BOOL toggle;
}
-( IBAction )doTransition:( id )sender;
@end
@implementation AppDelegate
-( void )awakeFromNib;
{
[[window contentView ] setWantsLayer: YES ];
CGColorRef green =
CGColorCreateGenericRGB (0, 0.45, 0, 1);
transitionLayer = [[[RippleLayer alloc ] init ] retain ];
[transitionLayer setFrame :
NSRectToCGRect([[window contentView ] frame ])];
[transitionLayer setBackgroundColor :green];
[transitionLayer setDelegate : self ];
[transitionLayer setBorderWidth :3];
// Keep the layer behind the button
[[[window contentView ] layer ]
insertSublayer :transitionLayer atIndex :0];
 
Search WWH ::




Custom Search