我一直在寻找,无法想象我如何做以下事情。我有一个UIPickerView(如图所示)我已修改为允许我从中选择min和seconds但我还想添加像CountDownTimer UIPickerView(显示)这样的标签,这样用户就可以知道从几秒钟开始的分钟数。
有关如何添加内联标签的任何想法。
答案 0 :(得分:2)
虽然不是很漂亮,可能是更好的方式,但你可以随时为#34;小时"创建一个单一的价值组件。并分别为" min"。
var hours = ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24"]
var hoursLabel = ["hours"]
var minutes = ["00","15","30","45"]
var minutesLabel = ["min"]
您可能还想调整列宽...这是一个例子。
//Adjust width of each picker column
func pickerView(pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat {
if (component == 1) {
return 55 //hours label
} else {
return 40 // all others
}
}