2011-06-10 93 views
1

我试图在更改值时减慢UISlider的动画。iOS - 如何减慢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

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

  • beginTrackingWithTouch:withEvent:
  • continueTrackingWithTouch:withEvent:
  • endTrackingWithTouch:withEvent: