2

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?

Alex Aghajanov
  • 294
  • 4
  • 17
  • Without code, or some screenshots of your storyboard setup I can't help much. Also, have you tried running the app? Your screenshot is of the preview, which isn't always as it appears in the app itself. – Gabe Spound Nov 18 '20 at 01:11
  • @GabeSpound I didn't include code because there were no properties that I imagined would work. And since there were none of those, there was no point testing. If you meant test my workaround solution in the picture, I did do that, and it was same as the preview. – Alex Aghajanov Nov 18 '20 at 01:59
  • @AlexAghajanov Did you checkout this [post](https://stackoverflow.com/questions/895830/how-to-change-color-of-selected-row-in-uipickerview)? – Harshil Patel Nov 18 '20 at 02:19
  • @Luffy I did, and although it is almost what I wanted, the color disappears when scrolling and reappears a half second after the wheel stops spinning. It overall doesn't look too good, and I wanted that color to stay even when scrolling. Thanks though. I guess this is just something that needs to be added to Swift. – Alex Aghajanov Nov 18 '20 at 22:46

2 Answers2

0

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
Gabe Spound
  • 568
  • 5
  • 28
  • Thanks for your answer. Unfortunately those didn't work which was a bit weird because the .tintColor property didn't change anything at all, whether I did it from storyboard or code. But still, thank you for the answer. – Alex Aghajanov Nov 18 '20 at 02:07
0

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

pickerView.subviews.last?.backgroundColor = .clear
Ina
  • 1
  • Sorry for extremely late reply. Your suggestion is useful for making the gray go away, but when using a color, like .yellow, the text is blocked out. Plus, the setting only gets activated after touching the pickerview. – Alex Aghajanov Jul 22 '21 at 19:53