Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISlider with variable scrubbing speeds (like iPod app)

Apple's iPod (Music) app has a slider (UISlider, I presume) with variable scrubbing speeds: the further away from the slider you drag vertically, the smaller the proportion of your horizontal dragging speed that is reflected in the value change of the slider. Has anyone figured out how to duplicate this behavior?

like image 805
matt Avatar asked Jan 02 '11 17:01

matt


2 Answers

Good question that inspired me to find a solution. I created a class named OBSlider that supports variable scrubbing speeds.

The solution in short: subclass UISlider, override -continueTrackingWithTouch:withEvent: and do the calculation of the change of self.value depending on the movement of the touch yourself. Thereby, you can freely influence the factor with which you want to multiply the touch movement to get to the new slider value.

For details, please read my blog post: OBSlider, a UISlider subclass with variable scrubbing speed.

like image 89
Ole Begemann Avatar answered Oct 03 '22 12:10

Ole Begemann


Nice work Ole ! I've made some minor modifications to get something more similar to the way iPod app slider's is working when sliding the finger closer to the UISlider ! Basically I handle a variable to track the value corresponding to the finger position, and if the user is getting closer, I apply a different formula (which is not perfect and could be improved a lot).

My fork is available here : http://github.com/sylverb/OBSlider

like image 39
Sylverb Avatar answered Oct 03 '22 12:10

Sylverb