I want to change the color of a UISegmentedControl on iOS 7. If I change the tint color in the Interface Builder, parts of it are drawn in the tint color, and parts are drawn in the standard blue.
The image ought to make this clearer. I have selected red as the tint color.
I get the same behaviour on both the simulator and on the device.
If I tap items on the segmented control, they're redrawn in the requested tint color.
If I specify the tint colour in viewDidLoad
, everything works correctly.
[segmentedControl setTintColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0]];
Why doesn't the Interface Builder color work?
(It feels like the color property hasn't applied correctly at the time the control is first drawn, but I have no evidence to back that up.)
I have the same bizarre behavior. The only workaround I could come up with was to switch the tintColor to something else and then switch it back in viewDidLoad
[self.mySegmentedControl setTintColor:[UIColor clearColor]];
[self.mySegmentedControl setTintColor:self.view.tintColor];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With