iOS - 如何减慢 UISlider 动画? [英] iOS - How to slow down UISlider animation?

查看:21
本文介绍了iOS - 如何减慢 UISlider 动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在更改值时减慢 UISlider 的动画速度.

I'm trying to slow down the animation of the UISlider when changing values.

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

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];

以及基于块的新方法:

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

我已经尝试过使用和不使用 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?

推荐答案

查看 OBSlider,一个具有可变擦洗速度的 UISlider 子类(如 iOS 上的 iPod 应用程序所示),Ole Begemann.我并不是说这正是你想要的,但你可以看到它是如何实现的,因为 代码托管在 GitHub.基本上,它继承了 UISlider 并覆盖了触摸跟踪方法:

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:

这篇关于iOS - 如何减慢 UISlider 动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆