具有可变擦洗速度的 UISlider(如 iPod 应用程序)
Apple 的 iPod(音乐)应用程序有一个具有可变滑动速度的滑块(我猜是 UISlider):垂直拖动距离滑块越远,反映在滑块值变化中的水平拖动速度比例就越小。有谁知道如何复制这种行为?
Apple's iPod (Music) app has a slider (UISlider, I presume) with variable scrubbing speeds: the further away from the slider you drag vertically, the smaller the proportion of your horizontal dragging speed that is reflected in the value change of the slider. Has anyone figured out how to duplicate this behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好问题激励我寻找解决方案。我创建了一个名为 OBSlider 的类,它支持可变的擦洗速度。
简而言之,解决方案是:子类 UISlider,重写
-continueTrackingWithTouch:withEvent:
并根据自己触摸的移动计算self.value
的变化。因此,您可以自由地影响与触摸移动相乘的因子以获得新的滑块值。详细内容请阅读我的博文:
OBSlider,具有可变擦洗速度的 UISlider 子类 。
Good question that inspired me to find a solution. I created a class named OBSlider that supports variable scrubbing speeds.
The solution in short: subclass UISlider, override
-continueTrackingWithTouch:withEvent:
and do the calculation of the change ofself.value
depending on the movement of the touch yourself. Thereby, you can freely influence the factor with which you want to multiply the touch movement to get to the new slider value.For details, please read my blog post:
OBSlider, a UISlider subclass with variable scrubbing speed.
干得好,奥莱!
我做了一些小的修改,以获得更类似于将手指滑动到 UISlider 时 iPod 应用程序滑块的工作方式!
基本上,我处理一个变量来跟踪与手指位置相对应的值,如果用户越来越近,我会应用不同的公式(这并不完美,可以改进很多)。
我的叉子可以在这里找到:http://github.com/sylverb/OBSlider
Nice work Ole !
I've made some minor modifications to get something more similar to the way iPod app slider's is working when sliding the finger closer to the UISlider !
Basically I handle a variable to track the value corresponding to the finger position, and if the user is getting closer, I apply a different formula (which is not perfect and could be improved a lot).
My fork is available here : http://github.com/sylverb/OBSlider