6. Subclassing UIView

In previous chapters, you’ve created several views: a UIButton, a UILabel, etc. But what exactly is a view?

• A view is an instance of a subclass of UIView.

• A view knows how to draw itself on the application’s window.

• A view is arranged within a hierarchy: the window (an instance of UIWindow) is itself a view and the root of the hierarchy. It has subviews (that appear on the window). Those views can also have subviews.

• A view handles touch events.

In this chapter, you are going to create your own UIView subclass that fills the screen with concentric circles as shown in Figure 6.1. You will also learn how to add text and enable scrolling and zooming.

Figure 6.1. View that draws concentric circles

Creating a Custom ...

Get iPhone 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.