The color of a UISegmentedControl in the UIKit is customizable only in the bar style mode, so if one uses the plain or bordered mode, the only possible color is blue. This could be a problem if blue does not fit well in your app or in a view.
The only way to support other colors is to subclass the UISegmentedColor and draw the view yourself. That’s what I did in the MCSegmentedControl class, here’s how it looks with a green tint color.

Here compared with the standard UISegmentedControl, bordered style (mine is above):

and plain style:

and now with some ugly colors and font:

My implementation is not pixel identical to the Apple one, but it is very similar.
I added support for customizing the tint (i.e. the background of the selected segment), the color of the not selected items and of the selected item, plus, if the segment has an image, it is drawn as a mask, so it will always be in the same color as the text.
Example
MCSegmentedControl *segmentedControl = [[MCSegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"first", @"second", [UIImage imageNamed:@"image.png", nil]];
// set frame, add to view, set target and action for value change as usual
segmentedControl.frame = CGRectMake(10.0f, 10.0f, 300.0f, 44.0f);
[self.view addSubview:anotherSC];
[segmentedControl addTarget:self action:@selector(segmentedControlDidChange:) forControlEvents:UIControlEventValueChanged];
// Set a tint color
segmentedControl.tintColor = [UIColor orangeColor];
// Customize font and items color
segmentedControl.selectedItemColor = [UIColor yellowColor];
segmentedControl.unselectedItemColor = [UIColor darkGrayColor];
If you use Interface Builder, add a normal UISegmentedControl, set its class as MCSegmentedControl in the Identity Inspector, set the Tint in the Attributes Inspector.
At the moment, animations and the following UISegmentedControl methods are not supported:
- (void)setContentOffset:(CGSize)offset forSegmentAtIndex:(NSUInteger)segment
Here are the files: MCSegmentedControl.zip
Nice example! I’ve created a subclass that does something similar, but lets you use custom selected/unselected colors with the bar style more :) Not sure it will get approved by the Apple store, but here it is:
http://uihacker.blogspot.com/2010/05/iphone-uisegmentedcontrol-custom-colors.html
Any idea if this will get through the AppStore approval process?
I haven’t submitted any app with this class yet. Hopefully I’ll do that in a few days, then I’ll post the results
I just tried your segmentedControl, don’t know, but for me it’s not working! I added your segmentedControl to a NavigationBar and can’t change it’s color :(
Any clues?
@Pablo, I tried to replicate what you wrote. It seems that when you assign the segmented control as the navigation item title view, the tintColor is reset. I’ve tried setting it after the titleView assignment and it seems to work.
segmentedControl.tintColor = [UIColor orangeColor];
Saved me a lot of time.
thanks.
Any update on whether the app store accepts this?
Hi,
great! really helpful – i tried it out successfully and eventually modified it to fit my needs (successfully too).
Thanks
The purpose of this class is to be able to customize color mainly right ?
Then this class is no good enough : the color you gave it is not respected. The gradient makes the color much brighter.