我需要一个timePicker几分钟和几秒钟,我想避免必须创建一个自定义UIpickerView。有快速的方法吗?我看到了一些教程(时/分/秒),但我只需要两列:分钟和秒。
答案 0 :(得分:0)
我认为您应该能够轻松地创建自己的UIPickerView实例或子类并使用Minutes and Seconds对其进行配置。
let arrMins = [0...60]
var arrSec = [0...60]
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 2
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
switch component {
case 1: return arrMins.count
case 2: return arrSec.count
}
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
switch component {
case 1: return "\(arrMins[row]) Mins"
case 2: return "\(arrSec[row]) Sec"
}
}