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?
To change the color/font of the selected segment titles, use setTitleTextAttributes with a state of . selected / UIControlStateSelected . If you create a segmented control with images, if the images are created as template images, then the segmented control's tintColor will be used to color the images.
First, we need to create our variable:Three variables to customize our view with a default value. Now we need to put our buttons in view but we have an array and this can be unlimited. The best to do this is create a Horizontal Stack View. Stack View makes the subViews with equal spacing without using any constraint.
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.
Have you tried setting the tint on the segmented control separately?
segmentedControl.tintColor = self.navigationController.navigationBar.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