iOS - 如何减慢UISlider动画?

时间:2011-06-10 19:46:42

标签: ios uislider uiviewanimation

我正在尝试在更改值时减慢UISlider的动画速度。

到目前为止,我已经尝试了旧的UIView动画方法:

[UIView beginAnimations:@"slider" context:nil];

[UIView setAnimationDuration:5.0];
[self.slider setValue:2 animated:YES];

[UIView commitAnimations];

基于新块的方法:

[UIView animateWithDuration:5.0 
         animations:^{
            [self.slider setValue:2 animated:YES];
                 }];

我尝试使用和不设置animated:YES值。在所有情况下,滑块只是以默认速度动画。

我应该考虑另一种策略来定制动画的速度吗?

我应该滑动子类并覆盖那里的任何东西吗?

1 个答案:

答案 0 :(得分:1)

查看OBSlider,这是一个UISlider子类,具有可变擦洗速度(如iOS上的iPod应用程序中所示)Ole Begemann。我并不是说它正是你想要的,但你可以看到自the code is hosted at GitHub以来它是如何实现的。基本上,它是子类UISlider并覆盖了触摸跟踪方法:

  • beginTrackingWithTouch:withEvent:
  • continueTrackingWithTouch:withEvent:
  • endTrackingWithTouch:withEvent:
相关问题