Implementing steps/snapping UISlider

后端 未结 6 1080
悲哀的现实
悲哀的现实 2020-12-23 02:07

I am trying to implement some form of snapping or steps with the UISlider. I have written the following code but it does not work as smooth as I hoped for. It works, but whe

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 02:36

    SWIFT VERSION

    Example: You want a slider to go from 1-10000 in steps of 100. UISlider setup is as follows:

    slider.maximumValue = 100
    slider.minimumValue = 0
    slider.continuous = true
    

    In the action func() for the slider use:

    var sliderValue:Int = Int(sender.value) * 100
    

提交回复
热议问题