The default UIPickerView color for text is black. There has been some updates to the language in Swift4. I have found my own solution and answered below.
Asked
Active
Viewed 1.7k times
5 Answers
12
You could use:
pickerView.setValue(UIColor.yellow, forKeyPath: "textColor")
This will only change the color for the currently selected row.

Matthew Bradshaw
- 1,843
- 3
- 13
- 21
-
12This will only change the color as you move the picker view for me. – P1xelfehler Aug 19 '18 at 12:21
8
Updated for Swift 5:
func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
return NSAttributedString(string: parksPickerData[row], attributes: [NSAttributedString.Key.foregroundColor: UIColor.white])
}

Colby Hill
- 811
- 1
- 8
- 13
4
I have a project with PickerViews and DatePickers (inside a TableViewCell), and I had to use a different sentence for each case.
For PickerViews:
func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
let titleData = "data"
let myTitle = NSAttributedString(string: titleData, attributes: [NSAttributedString.Key.foregroundColor: UIColor.lightGray])
return myTitle
}
For DatePicker:
datePicker.setValue(UIColor.lightGray, forKey: "textColor")

ainareta685
- 149
- 1
- 6