Graphics Reference
In-Depth Information
LISTING 6-3
Continued
// Give the Gaussian blur filter a name
[blurFilter setName : @”blur” ];
[blurLayer setFilters :[ NSArray arrayWithObject :blurFilter]];
}
We have created a CALayer -derived class called BlurLayer that we add to the BlurView
view object. The BlurLayer class simply manages the image content of the layer. The
image for each instance of the view is set in the -applicationDidFinishLaunching
method, found in the application delegate class, as shown in Listing 6-4.
LISTING 6-4
Initialization of BlurView Objects
- ( void )applicationDidFinishLaunching:( NSNotification *)aNotification;
{
NSString *iconPath1 = [[ NSBundle mainBundle ]
pathForResource : @”desktop”
ofType : @”png” ];
NSString *iconPath2 = [[ NSBundle mainBundle ]
pathForResource : @”fwdrive”
ofType : @”png” ];
NSString *iconPath3 = [[ NSBundle mainBundle ]
pathForResource : @”pictures”
ofType : @”png” ];
NSString *iconPath4 = [[ NSBundle mainBundle ]
pathForResource : @”computer”
ofType : @”png” ];
NSImage *image1 = [[NSImage alloc ]
initWithContentsOfFile :iconPath1];
NSImage *image2 = [[NSImage alloc ]
initWithContentsOfFile :iconPath2];
NSImage *image3 = [[NSImage alloc ]
initWithContentsOfFile :iconPath3];
NSImage *image4 = [[NSImage alloc ]
initWithContentsOfFile :iconPath4];
[blurView1 setLayerImage:image1];
[blurView2 setLayerImage:image2];
[blurView3 setLayerImage:image3];
[blurView4 setLayerImage:image4];
}
 
Search WWH ::




Custom Search