Possible Duplicate:
How to change font color of UISegmentedControl
Is it possible to keep different font colors for the text of selected
and unselected
segment
of UISegmentedControl
. Any help will be appreciated.
Possible Duplicate:
How to change font color of UISegmentedControl
Is it possible to keep different font colors for the text of selected
and unselected
segment
of UISegmentedControl
. Any help will be appreciated.
// Instantiate as usual
NSArray *items = [NSArray arrayWithObjects:@"first", @"second", [UIImage imageNamed:@"image.png"], nil];
MCSegmentedControl *segmentedControl = [[MCSegmentedControl alloc] initWithItems:items];
// 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:segmentedControl];
[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)setWidth:(CGFloat)width forSegmentAtIndex:(NSUInteger)segment;
- (void)setContentOffset:(CGSize)offset forSegmentAtIndex:(NSUInteger)segment
Here are the files: