iOS 中的双范围可移动滑块组件
我想实现一个类似滑块的组件,就像 Roambi 截图底部的组件一样。对于那些没有使用过 Roambi 的人来说,这个滑块是双范围的,即您可以从两端的蓝色条定义范围。然后,为了指示您感兴趣的数据区域,您可以将这些蓝色条之间的灰色区域向左/右移动。
为了实现这一点,我想到了两件事:
左右蓝色条是 UIView 。我处理这些视图上的触摸事件来定义范围。这两个栏之间的中间区域也是 UIView。我处理此视图上的触摸事件以将其左/右移动以定义数据区域。
我可以实现双范围 UISlider 以获得蓝色条的功能。 (我已经学会了如何做到这一点。)但是我不知道如何移动滑块的主体来定义数据范围。这可能吗?
另外,是否可以有另一种方法来实现这一点?
I want to implement a slider-like component like the one at the bottom of this screenshot taken from Roambi. For those who haven't used Roambi, this slider is double ranged, i.e. you can define the ranges from the blue bars at the two ends. And then to indicate which data region you're interested, you move the grey area in between these blue bars to the left/right.
To implement this, two things come to my mind:
The left and right blue bars are UIViews. I handle touch events on these views to define the range. The middle area in between these two bars is also a UIView. I handle touch events on this view to move it left/right in order to define the data region.
I can implement a double ranged UISlider in order to get the functionality of the blue bars. (I already learned how to do this.) But then I don't know how to move the body of the slider to define the data range. Is this possible?
Also, could there be another way of implementing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会发现这些项目很有趣:
You might find these projets interesting:
自定义 iOS 控件,为您提供类似 UISlider 的 UI,用于选择一系列值。
https://github.com/muZZkat/NMRangeSlider
A custom iOS control that gives you a UISlider like UI for selecting a range of values.
https://github.com/muZZkat/NMRangeSlider