Gold Challenge: Shadows and Gradients
At this time, adding drop shadows and drawing with gradients can only be done using Core Graphics.
To create a drop shadow, you install a shadow on the graphics context. After that, anything opaque that you draw will have a drop shadow. The shadow has an offset (which is expressed with an CGSize), and a blur in points. Here is the declaration of the method used to install the shadow on the graphics context:
void CGContextSetShadow ( CGContextRef context, CGSize offset, CGFloat blur);
(There is a version that takes a color, but you almost always want a dark shadow.)
There is no unset shadow function. Thus, you will need to save the graphics state before setting the shadow and then restore it after ...
Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.