Graphics Reference
In-Depth Information
blurry so our starting value, fromValue , is set to 0.0 and our ending value, toValue , is set
to 5.0 . However, if the toggle is set, we want to animate to clear so the starting value is
5.0 and our ending value is 0.0 .
Notice also that Listing 6-7 doesn't contain the - setAutoreverses call that's found in
Listing 6-6. This call must be removed or set to NO for the effect to be “sticky”; otherwise
it returns to its starting value and overrides - setFillMode: .
Next, we have changed the -setRemovedOnCompletion call to NO . This tells the layer not to
remove the animation when it has completed.
Finally, we have added a call to -setFillMode:kCAFillModeForwards that tells the anima-
tion to leave the resulting value at whatever we specified in the - setToValue field.
Each icon now retains the blur on the first click and returns to its original value on a
second click, making the Core Animation layer-based-button “sticky.” In Figure 6-4, you
can see that two of the icons are blurry because they have each been clicked once and
retain their sticky state.
FIGURE 6-4
Sticky Blur
Controlling Filter Values with Data Bindings
Filter parameters are accessible and modifiable using KVC. This enables you to use data
bindings to create layers with complex filtering and control those filters using standard
Cocoa controls, such as sliders.
You might recall from the previous section that when we instantiated the CABasic
Animation object on a mouse down event, we used the key-path filters.blur.
inputRadius on the layer. filters represents the NSArray of filters available, blur is the
 
Search WWH ::




Custom Search