Information Technology Reference
In-Depth Information
kCGGradientDrawsBeforeStartLocation+
kCGGradientDrawsAfterEndLocation);
CGContextRestoreGState(aContext);
CGGradientRelease(myGradient);
CGColorSpaceRelease(myRGB);
}
NOTE
This is lots of code for a simple effect; the Core Graphics library in iOS isn't outstandingly easy to work with. This
chapter isn't a primer on Core Graphics, so don't try to remember the details. The key point is that UIView can be
customized to suit your application's requirements. Subclassing isn't limited to graphics. For example, you also
can customize how UIView responds to touch events or other user actions. In a more complex application, you
might copy touch events, process them in your subclass, and resend them to other objects for further processing.
In practice, subclassing is almost infinitely flexible.
Assigning the subclass in IB
If you build and run the application now, you get the result shown in Figure 8.6. The code has been added. But
it doesn't run.
FIGURE 8.6
In subclassing UIView, the first step is to create subclass files and edit their code, but this step on its own isn't
enough.
Search WWH ::




Custom Search