UIPickerView change separator color

Can we change the color of saparator in UIPickerView with below code. I am afraid that accessing subviews could cause Apple rejection. Is it conidered as accessing private api?


[[pickerView.subviews objectAtIndex:1] setBackgroundColor:COLOR]; [[pickerView.subviews objectAtIndex:2] setBackgroundColor:COLOR];

I couldn't figure it out so I ended up adding a UILabel behind the (transparent) UIPickerView. It worked well. (app: Beat The Market, Buy/Sell page, quantity picker)

Thanks for reply.

Below code works but need to know if app gets rejected because of this. I understand that we cannot rely on subviews but it works for now.


[[pickerView.subviews objectAtIndex:1] setBackgroundColor:COLOR];

[[pickerView.subviews objectAtIndex:2] setBackgroundColor:COLOR];

Please take note
This will cause crash in iOS 14 because the new picker view contains only two subviews (index 0 and index 1)
UIPickerView change separator color
 
 
Q