5 Views: Redrawing and UIScrollView

In this chapter, you are going to see how views are redrawn in response to an event. In particular, you will update Hypnosister so that when the user touches the BNRHypnosisView, its circle color will change. A change in color which will require the view to redraw itself. Later in the chapter, you will also add a UIScrollView to Hypnosister’s view hierarchy.

The first step is to declare a property for the color in BNRHypnosisView. In earlier applications, you declared properties in header files. You can also declare properties in class extensions.

Open BNRHypnosisView.m and add the following code near the top of the file.

#​i​m​p​o​r​t​ ​"​B​N​R​H​y​p​n​o​s​i​s​V​i​e​w​.​h​"​

@​i​n​t​e​r​f​a​c​e​ ...

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.