iOS - How to slow down UISlider animation?

社会主义新天地 提交于 2019-12-23 02:43:14

问题


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?

Should I subclass the slider and override anything there?


回答1:


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:


来源:https://stackoverflow.com/questions/6311354/ios-how-to-slow-down-uislider-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!