O'Reilly logo

The Core iOS Developer’s Cookbook, Fifth Edition by Rich Wardwell, Erica Sadun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Recipe: Building Buttons

When using the UIButtonTypeCustom style, you supply all button art. The number of images depends on how you want the button to work. For a simple pushbutton, you might add a single background image and vary the label color to highlight when the button is pushed.

For a toggle-style button, you might use four images: for the “off” state in a normal presentation, the off state when highlighted (that is, pressed), and two more for the “on” state. You choose and design the interaction details, making sure to add local state (the Boolean isOn instance variable in Recipe 2-1) to extend a simple pushbutton to a toggle. If you supply a normal image to buttons and do not specify highlight or disabled images, iOS automatically ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required