The tint that usually shows on a UISegmentedControl on the selected button isn't showing when I set the whole nav bar to black (self.navigationController.navigationBar.tintColor = [UIColor blackColor];).
Is this a bug or something I'm missing?
The tint that usually shows on a UISegmentedControl on the selected button isn't showing when I set the whole nav bar to black (self.navigationController.navigationBar.tintColor = [UIColor blackColor];).
Is this a bug or something I'm missing?
Have you tried setting the tint on the segmented control separately?
segmentedControl.tintColor = self.navigationController.navigationBar.tintColor;
In order for the tint color to show, there are a couple of requirements:
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
It's required for the tintColor
to work.
You also mention that you have the tintColor
set to [UIColor blackColor]
. Unfortunately, the UISegmentedControl
will always display the selected segment with a darker color, never a lighter. Try setting your tintColor
to [UIColor darkGrayColor]
and you should be able to see the selected segment change color.
Try using tint color [UIColor colorWithWhite:80.0/255.0 alpha:1.0]
.
This makes the black color less black and allows the selected segment to become darker after selection. You can set the white component as suitable.
Sample code:
UISegmentedControl *aSegmentedControl = [[UISegmentedControl alloc] initWithItems:arrItems];
aSegmentedControl.frame = CGRectMake(55, 382, 210, 32);
aSegmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
aSegmentedControl.selectedSegmentIndex = 0;
aSegmentedControl.tintColor = [UIColor colorWithWhite:80.0/255.0 alpha:1.0];
On iphone 3.0, if you want add the Segmented Control in a NavigationController, do that first and change the tintcolor after u did that.