Ray Lei
Ray Lei

Reputation: 31

iOS 14 UIPickerView color of the selected row

enter image description here

in iOS 14 the UIPickerView has default a grey background on the selected Row,

I can't find a way to change it

Upvotes: 2

Views: 1599

Answers (2)

caminante errante
caminante errante

Reputation: 305

Just to clarify, the code:

if #available(iOS 14.0, *) { pickerView.subviews[1].backgroundColor = .clear }

needs to go in the following protocol method:

func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {

}

Upvotes: 2

Ray Lei
Ray Lei

Reputation: 31

enter image description here I solved my problem like this

if #available(iOS 14.0, *) { pickerView.subviews[1].backgroundColor = .clear }

Upvotes: 0

Related Questions