Search code examples
iphoneuislider

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?


Solution

  • 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.