Standard Control Types

One perk of Cocoa Touch is the collection of control classes in UIKit. A user interface control pattern includes one or more user interface elements that work together to solve an input problem. It’s clear that Apple put a lot of thought into the design of its controls, and developers can easily take advantage of that work. This section will introduce you to the most common types of controls.

Buttons

The simplest controls are buttons. The UIButton class is the foundation for most buttons, including custom button subclasses. Buttons are used extensively in Cocoa Touch applications and can be customized through display attributes or with specialized drawing code.

Creating buttons

You can use the buttonWithType: method of UIButton to create buttons of several different types. Table 7-2 describes the various UIButtonType keys.

Table 7-2. UIButtonType keys

UIButtonType keyDescription
UIButtonTypeCustomNo button style. Instead, a custom drawRect: method should be defined.
UIButtonTypeRoundedRectA rectangular button with rounded corners and a centered title. Used for all general-purpose buttons.
UIButtonTypeDetailDisclosureA circular button with a centered chevron (>). Used to display details of an associated object or record.
UIButtonTypeInfoLightA light-colored, circular button with an italicized lowercase “i” character. Used to flip a view over to display settings or additional information.
UIButtonTypeInfoDarkA dark-colored, circular button with an italicized lowercase ...

Get Programming the iPhone User Experience 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.