iOS how to make slider stop at discrete points

后端 未结 5 2217
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 06:21

I would like to make a slider stop at discrete points that represent integers on a timeline. What\'s the best way to do this? I don\'t want any values in between. It woul

5条回答
  •  情歌与酒
    2020-12-13 06:48

    To make the slider "stick" at specific points, your viewcontroller should, in the valueChanged method linked to from the slider, determine the appropriate rounded from the slider's value and then use setValue: animated: to move the slider to the appropriate place. So, if your slider goes from 0 to 2, and the user changes it to 0.75, you assume this should be 1 and set the slider value to that.

提交回复
热议问题