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 a Star Slider

Rating sliders allow users to grade items such as movies, software, and so forth by dragging their fingers across a set of images. It’s a common task for touch-based interfaces but one that’s not well served by a simple UISlider instance, with its floating-point values. Instead, a picker like the one built in Recipe 2-6 limits a user’s choice to a discrete set of elements, producing a bounded integer value between zero and the maximum number of items shown. As a user’s finger touches each star, the control’s value updates, and a corresponding event is spawned, allowing your application to treat the star slider like any other UIControl subclass.

The art is arbitrary. The example shown in Figure 2-6 uses stars, but ...

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