Graphics Reference
In-Depth Information
name we provided to the filter upon instantiation for later identification, and
inputRadius is the name of the filter field we wanted to manipulate. This same key path
can be used when setting up bindings in Interface Builder. The difference is that we must
first make the CALayer accessible to Interface Builder by making it a property of the
AppDelegate class, as shown in Listing 6-8.
LISTING 6-8
AppDelegate Declaration
@interface AppDelegate : NSObject
{
IBOutlet NSView *displayView;
CALayer *imageLayer;
}
@property ( retain ) CALayer *imageLayer;
@end
In the AppDelegate implementation, we have to @synthensize the imageLayer object.
Prior to Objective-C 2.0, you had to explicitly create setters and getters for your instance
variables and you had to wrap changes you made to your instance variables in calls to
-willChangeValueForKey and - didChangeValueForKey for your object to be KVC-
compliant, which is required for bindings to work. Now, with Objective-C 2.0, this is
done automatically when you make your ivar a @property and use the @synthesize
keyword. The implementation code to synthesize the imageLayer object is in Listing 6-9.
LISTING 6-9
AppDelegate Implementation
@implementation AppDelegate
@synthesize imageLayer;
Switch to Interface Builder and add a slider for each of the filters we want to apply to the
imageLayer object. In Figure 6-5, you can see that we have added sliders for a Gaussian
Blur, Hue, Saturation, Contrast, and Brightness.
Before we can data bind the sliders, the filters need to be added to the imageLayer . For
this, call -setFilters on the layer, as shown in Listing 6-10.
 
Search WWH ::




Custom Search