Drawing Text and Shadows

While we are talking about drawing, let’s add some text with a shadow to the view, as shown in Figure 6.3.

Figure 6.3  View that draws text

View that draws text

Open HypnosisView.m and add the following code to the end of your drawRect: method:

 ​ ​ ​ ​f​o​r​ ​(​f​l​o​a​t​ ​c​u​r​r​e​n​t​R​a​d​i​u​s​ ​=​ ​m​a​x​R​a​d​i​u​s​;​ ​c​u​r​r​e​n​t​R​a​d​i​u​s​ ​>​ ​0​;​ ​c​u​r​r​e​n​t​R​a​d​i​u​s​ ​-​=​ ​2​0​)​ ​ ​ ​ ​{​ ​ ​ ​ ​ ​ ​ ​ ​C​G​C​o​n​t​e​x​t​A​d​d​A​r​c​(​c​o​n​t​e​x​t​,​ ​c​e​n​t​e​r​.​x​,​ ​c​e​n​t​e​r​.​y​,​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​c​u​r​r​e​n​t​R​a​d​i​u​s​,​ ​0​,​ ​M​_​P​I​ ​*​ ​2​.​0​,​ ​Y​E​S​)​;​ ​ ​ ​ ​ ...

Get iOS Programming: The Big Nerd Ranch Guide, Second Edition 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.