iOS - How to slow down UISlider animation?
I'm trying to slow down the animation of the UISlider when changing values.
So far, I've tried the old UIView animation method:
[UIView beginAnimations:@"slider" context:nil];
[UIView setAnimationDuration:5.0];
[self.slider setValue:2 animated:YES];
[UIView commitAnimations];
And the new blocks based method:
[UIView animateWithDuration:5.0
animations:^{
[self.slider setValue:2 animated:YES];
}];
I've tried with and without the animated:YES
value set. In all cases, the slider simply animates at the default speed.
Is there another tactic I should be looking at to customize the speed of the animation?
开发者_JAVA技巧Should I subclass the slider and override anything there?
Check out the OBSlider, a UISlider subclass with variable scrubbing speed (as seen in the iPod app on iOS) by Ole Begemann. I'm not saying it is exactly what you want but you can see how it is implemented since the code is hosted at GitHub. Basically, it subclasses UISlider
and overrides the touch tracking methods:
beginTrackingWithTouch:withEvent:
continueTrackingWithTouch:withEvent:
endTrackingWithTouch:withEvent:
精彩评论