I want to move a UISlider from minValue to maxValue in a loop when you hit a button and stop it at the current position when hitting the button again, I want to use Swift.
The main problem i got is that the function slider.setValue() is way to fast, I want the animation more slowly.
@IBAction func setSliderValue(_ sender: UIButton){
slider.setValue(100, animated: true)
print("The value of the slider is now \(slider.value)")
sliderValue = Int(slider.value)
}
This code is working, though the slider only moves from left to right, not from right to left when he reached maximumValue, it should move from left to right and then right to left until the invalidated.
You can use time to Automatically Move slider. Create NSTimer variable in global scope: Also create one Bool variable in global scope for checking if Need to revise it.
start timer when you want to animate it:
On tImer Action, You can write code to change value of Slider:
On Button Action, You can just stop the timer,