Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISegmentedControl tint color isn't drawn correctly on iOS 7

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.

enter image description here

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.)

like image 966
Ian Howson Avatar asked Oct 08 '13 04:10

Ian Howson


1 Answers

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];
like image 81
lidsinker Avatar answered Nov 19 '22 03:11

lidsinker