'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



Solution 1:[1]

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 {

}

Solution 2:[2]

enter image description here I solved my problem like this

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 caminante errante
Solution 2 Ray Lei