According to the Apple documentation , you can programmatically set a UISlider value with smooth animation. I am trying to do this with a custom view controller, the user interface is determined from the storyboard.
Context
In my example, I am trying to update the value of a slider with a custom view controller, the user interface is determined from the storyboard. The example shows only one slider.
When the user releases the slider, the reset value is 0 .
The code
import UIKit class ViewController: UIViewController { @IBOutlet var mySlider: UISlider! @IBAction func resetSlider() { mySlider.setValue(0, animated:true) NSLog("Reset!") } override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } }
resetSlider is associated with the Touch Up Inside event.
Problem
When resetSlider is called, the value changes on the interface, but it is not animated (the value simply "jumps" to 0). My goal is for the value to gracefully shift back to zero.
Note: "Reset!" displayed only once (per click), which indicates that resetSlider not called multiple times.
Why not UISlider animation?
Video
Since IB is so visual, here is a video about the situation, password code
ios animation swift
slifty
source share