Search code examples
iosuislider

Making a UISlider move back and forth on its own


In my current project I've created an app that utilizes the position of the UISlider in relation to a target value displayed to the user. I've got full functionality however I'm now trying to spice it up a bit.

Is it possible to set the UISlider to move from (minimum through maximum) than (maximum through minimum) back and forth on its own when the user enters the app rather than having them drag it?

Thoughts:

Possibly use a looping sequence?

Not looking for someone to code this for me I quite enjoy that part. Just looking for guidance.


Solution

  • Further to the NSTimer answer, I wouldn't suggest using that, but CADisplayLink instead. Similar process, but instead of using NSTimer use CADisplayLink.

    CADisplayLink synchronises with the screen refresh rate, so you can adjust the animation and slider value based on current frame, so the animation appears smooth.

    http://patzearfoss.com/2011/09/02/more-cadisplaylink/