我怎样才能制作一个水平选择器?
我想为我的应用程序制作一个水平选择器,但我对这一切还很陌生。有人可以提供一个易于遵循的指南来指导我如何做到这一点吗?
I want to make a horizontal picker for my app, but I'm kinda new at all this. Could someone provide an easy to follow guide on how I'd make this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的方法是使用启用分页的
UIScrollView
来伪造您自己的。实际上相当简单,将滚动视图与您自己的自定义图形视图重叠。The best way is to fake your own using
UIScrollView
with pagination enabled. It's actually fairly easy, overlaying a scroll view with your own views for custom graphics.适用于 iOS 的开源水平选择器组件刚刚在 GitHub 上发布。
可以按如下方式将其添加到 UITableViewCell(在
tableView:cellForRowAtIndexPath:
中):无论如何,它都不具备 UIPickerView 的所有功能,但它说明了实现控件的一种可能方法(一个 UIScrollView 包含一个带有多个用于标记的 CATextLayers 的 UIView),并且有一些不错的功能,例如捕捉到标记。
An open-source horizontal picker component for iOS has just been released on GitHub.
It can be added to a UITableViewCell as follows (in
tableView:cellForRowAtIndexPath:
):It doesn't have all of the features of a UIPickerView by any means, but it illustrates one possible way to implement a control (a UIScrollView containing a UIView with multiple CATextLayers for the markers) and has a couple of nice features like snapping to markers.