Recipe: Adding a Slider with a Custom Thumb

UISlider instances provide a control that allows users to choose a value by sliding a knob (called its thumb) between its left and right extents. You’ve seen sliders in the Music application, where the UISlider class is used to control volume.

Slider values default to 0.0 for the minimum and 1.0 for the maximum, although you can easily customize these in the IB Attributes inspector or by setting the minimumValue and maximumValue properties. To stylize the ends of the control, add a related pair of images (minimumValueImage and maximumValueImage) that reinforce those settings. For example, you might show a snowman on one end and a steaming cup of tea on the other for a slider that controls temperature ...

Get The Core iOS Developer’s Cookbook, Fifth Edition 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.