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:

v​o​i​d​ ​C​G​C​o​n​t​e​x​t​S​e​t​S​h​a​d​o​w​ ​(​
 ​ ​ ​C​G​C​o​n​t​e​x​t​R​e​f​ ​c​o​n​t​e​x​t​,​
 ​ ​ ​C​G​S​i​z​e​ ​o​f​f​s​e​t​,​
 ​ ​ ​C​G​F​l​o​a​t​ ​b​l​u​r​)​;​

(There is a version that takes a color, but you almost always want a dark shadow.)

There is no unset shadow function. Thus, you ...

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.