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 po
If anyone also needs snaping animation then can do the following:
You can do the same from swift slider.isContinuous = false
@IBAction
in your ViewController
: @IBAction func sliderMoved(_ slider: UISlider){
let stepCount = 10
let roundedCurrent = (slider.value/Float(stepCount)).rounded()
let newValue = Int(roundedCurrent) * stepCount
slider.setValue(Float(newValue), animated: true)
}
I was inspired by this answer