简体   繁体   中英

How to change UIPickerView's selected tint color in iOS 14?

One of iOS 14's changes included changing the UIPickerView to have a light gray selected row tint color. I was wondering if there is any way to change this or even access this property. I looked in the storyboard's attributes inspector and there didn't seem to be anything. Same with the code, autocomplete didn't bring up any selected tint related properties. Also looked around the internet but since it is a relatively new feature there wasn't anything helpful. Before iOS 14 I could put a UIView with my chosen color underneath to simulate this, but this update takes that away as the gray is still visible, and it looks bad. Here's a pic:

https://i.stack.imgur.com/BmoNO.png

I was wondering if there are any real ways to do this. Also, a good solution would be to disable the light gray, because then I could use the strategy I show above. Any tips?

Without more information I can't say for sure, but in your View Controller class, access the UIPickerView and you can change it's tintColor and isOpaque properties. Something like this I would imagine.

pickerView.isOpaque = false
pickerView.tintColor = .clear

I looked into subviews. On delegate of a UIPickerView, within method didSelectRow I was able to set background.

pickerView.subviews.last?.backgroundColor = .clear

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM