iOS如何使滑块停在离散点 [英] iOS how to make slider stop at discrete points

查看:113
本文介绍了iOS如何使滑块停在离散点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个代表时间轴上整数的离散点上制作滑块。最好的方法是什么?我不希望它们之间有任何价值。如果滑块也可以捕捉到每个离散点的位置,那将会很棒。

I would like to make a slider stop at discrete points that represent integers on a timeline. What's the best way to do this? I don't want any values in between. It would be great if the slider could "snap" to position at each discrete point as well.

推荐答案

制作滑块坚持在特定点,你的viewcontroller应该在从滑块链接的valueChanged方法中,从滑块的值确定适当的圆角,然后使用setValue:animated:将滑块移动到适当的位置。因此,如果滑块从0变为2,并且用户将其更改为0.75,则假设此值应为1并将滑块值设置为该值。

To make the slider "stick" at specific points, your viewcontroller should, in the valueChanged method linked to from the slider, determine the appropriate rounded from the slider's value and then use setValue: animated: to move the slider to the appropriate place. So, if your slider goes from 0 to 2, and the user changes it to 0.75, you assume this should be 1 and set the slider value to that.

这篇关于iOS如何使滑块停在离散点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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