I’m trying to create a UISlider that lets you choose from an array of numbers. Each slider position should be equidistant and the slider should snap to each position, rather than smoothly slide between them. (This is the behavior of the slider in Settings > General > Text Size, which was introduced in iOS 7.)
The numbers I want to choose from are: -3, 0, 2, 4, 7, 10, and 12.
(I’m very new to Objective-C, so a complete code example would be much more helpful than a code snippet. =)
Some of the other answers work, but this will give you the same fixed space between every position in your slider. In this example you treat the slider positions as indexes to an array which contains the actual numeric values you are interested in.
Edit: Here’s a version in Swift 4 that subclasses UISlider with callbacks.