简体   繁体   English

UIDatePicker.Mode.countDownTimer:我可以只显示五乘五分钟吗?

[英]UIDatePicker.Mode.countDownTimer: can I display minutes only five by five?

Is it possible to use a UIDatePicker with .datePickerMode =.countDownTimer , but setting minutes five by five?是否可以将UIDatePicker.datePickerMode =.countDownTimer使用,但将分钟设置为五乘五? I mean, having only 0, 5, 10, 15... as possible values for the minutes?我的意思是,只有0, 5, 10, 15...作为分钟的可能值?

Or do I need to write my own UIPickerView for this?或者我需要为此编写自己的UIPickerView吗?

Thank you for your help谢谢您的帮助

Yes, You should set timeInterval: 5.是的,您应该设置 timeInterval:5。

The interval is measured seconds so for it to perform like a standard clock we should set this argument to 1. if you want to count 5 by 5 second.间隔以秒为单位,因此要让它像标准时钟一样运行,我们应该将此参数设置为 1。如果您想以 5 秒为单位计算 5。 You shal pass to 5 as a parameter.您应将 5 作为参数传递给。

func runTimer() { 
     timer = Timer.scheduledTimer(timeInterval: 5, target: self,   selector: (#selector(TimeViewController.updateTime)), userInfo: nil, repeats: true)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM