如何更改 UIPickerView 中文本的高度?是否可以?我想降低默认高度。
最佳答案
SWIFT 2.2
在pickerView的委托(delegate)中实现pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) 方法。
func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) -> UIView {
let label: UILabel = UILabel(frame: CGRectMake(0, 0, scalePicker!.frame.size.width / 2, scalePicker!.frame.size.height / 7))
label.textColor = UIColor.whiteColor()
label.font = UIFont(name: "Gotham-Medium", size: 20)
switch component {
case 0:
label.text = height_array[row] as? String
label.textAlignment = .Center
case 1:
label.text = unit_Arr[row] as? String
label.textAlignment = .Left
default:
break
}
return label
}
关于ios - 更改 UIPickerView 中文本的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44276983/