Shadows

To add a shadow to a drawing, give the context a shadow value before drawing. The shadow position is expressed as a CGSize, where the positive direction for both values indicates down and to the right. The blur value is an open-ended positive number; Apple doesn’t explain how the scale works, but experimentation shows that 12 is nice and blurry, 99 is so blurry as to be shapeless, and higher values become problematic.

Figure 15-9 shows the result of the same code that generated Figure 15-8, except that before we start drawing the arrow into the real context, we give the real context a shadow with this line:

CGContextSetShadow(con, CGSizeMake(7, 7), 12);
Drawing with a shadow

Figure 15-9. Drawing with a shadow

Get Programming iOS 4 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.