Изменение высоты вида строки в методе делегата pickerView:
public func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
for view in pickerView.subviews {
if view.frame.size.height < 1 {
var frame = view.frame
frame.size.height = 2
view.frame = frame
view.backgroundColor = UIColor.black
}
}
let label = UILabel()
label.text = "Test Text" //remember to change it to the real data
label.textAlignment = NSTextAlignment.center
return label
}
Не забудьте установить делегата PickerView:
self.pickerView.delegate = self //or do this in XIB or Storyboard.
Эффекты: