iOS - 如何减慢 UISlider 动画速度?
我试图在更改值时减慢 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
值集。在所有情况下,滑块仅以默认速度进行动画处理。
我是否应该考虑另一种策略来自定义动画的速度?
我应该对滑块进行子类化并覆盖其中的任何内容吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看OBSlider,具有可变滑动速度的 UISlider 子类(如 iOS 上的 iPod 应用程序所示),作者 奥勒·贝格曼。我并不是说这正是您想要的,但您可以看到它是如何实现的,因为 代码托管在 GitHub 上。基本上,它是
UISlider
的子类,并覆盖触摸跟踪方法:beginTrackingWithTouch:withEvent:
continueTrackingWithTouch:withEvent:
endTrackingWithTouch:withEvent:
代码>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: