Graphics Reference
In-Depth Information
The instance variables blurView1 , blurView2 , blurView3 , and blurView4 are BlurView
instances, and each one has been connected to custom views in Interface Builder. You can
see what these custom views look like in Figure 6-3.
FIGURE 6-3
Custom Views in Interface Builder
Receiving User Input
Core Animation layers cannot receive mouse events; however, their backing views do. In
the view initialization code (Listing 6-4), we applied the layer's filter(s) for later use when
the view receives a click.
To receive a click, tell BlurView to accept mouse clicks by adding to the view the code in
Listing 6-5.
LISTING 6-5
Enable View to Receive Events
-( BOOL )acceptsFirstResponder;
{
return YES ;
}
A first responder is a responder in the responder chain that is given the first chance to
respond to an event such as a mouse click or key press. With this code in Listing 6-5, we
are informing the event system that our window should be given a chance to respond to
events sent to it. In this case, these are simply mouse clicks. After we have established
that our view should handle its own events in this way, we can implement the code that
we want to run when we receive the event. In the -mouseDown view delegate, set up a
basic animation for changing the value of the blur filter's input radius, as shown in
Listing 6-6.
 
Search WWH ::




Custom Search