[英]How to create a simple(custom) time picker with just two colomns, hour and minute?
I want to make a simple TimePicker like this : 我想要这样一个简单的TimePicker:
If I use UITableView then how do I know that middle row/cell is selected ? 如果我使用UITableView,那么我如何知道选择了中间行/单元格? Also the last row/cell will never be in middle.
而且最后一行/单元格永远不会在中间。 Apart from that, It has to be two tableViews as both hour selection and minute selection needs to be separate.
除此之外,它必须是两个tableViews,因为小时选择和分钟选择都需要分开。 If I use two scrollViews , still how to figure out when an item is exactly in the middle and should be considered as selected item.
如果我使用两个scrollViews,仍然如何确定项目何时恰好在中间,应视为已选项目。
I could not find any customization options in the default date time picker. 我在默认日期时间选择器中找不到任何自定义选项。 Secondly , my picker is very simple one, yet I am not able to find a proper method to create this type of picker.
其次,我的选择器非常简单,但是我找不到合适的方法来创建这种类型的选择器。 I cannot use the default picker, because it has different design which is not what I want.
我不能使用默认选择器,因为它具有不同的设计,这不是我想要的。
Any help is appreciated. 任何帮助表示赞赏。 Thanks
谢谢
If I understand you right, you want only time in your picker and design it? 如果我理解正确,那么您只想在选择器中花时间设计一下吗? From storyboard you can select wheather it is "Time", "Date", "Date & time" etc. Just slect your picker and from right select attributes.
在情节提要中,您可以选择“时间”,“日期”,“日期和时间”等。只需选择您的选择器,然后从正确的选择属性中进行选择即可。
But for design I suggest you to try these lines of codes: 但是对于设计,我建议您尝试以下代码行:
datePicker.backgroundColor = UIColor.whiteColor() //It is for background color
datePicker.setValue(UIColor.whiteColor(), forKeyPath: "textColor")//It is for text color
self.datePicker.performSelector("_setHighlightColor:", withObject:Constants.Colors.mainHeaderColor) //This should be higlight color
Apple have a specific picker specifically for dates and times. 苹果有专门针对日期和时间的特定选择器。
let picker = UIDatePicker()
picker.datePickerMode = UIDatePickerMode.Time
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.