Here is my tab bar:
The following image shows the program being run and the "NEWS" item selected:
It is clear the bar tint color is working fine as I want !
But the tintColor only affects the image and not the text.
Also, when the an item is selected (as seen above, news) the item color goes blue! How do I prevent this from happening? I want it to stay white.
Why is the text changing to a white color when selected but not when it is unselected?
I basically want the item color and text color to be white all the time.
How do I achieve this? Thanks for any help.
Does it require swift code for each individual item?
EDIT:
From UITabBarItem class docs:
The clue is not whether you use UIImageRenderingModeAlwaysOriginal, the important thing is when to use it.
To prevent the grey color for unselected items, you will just need to prevent the system colouring for the unselected image. Here is how to do this:
As you can see, I asked iOS to apply the original color (white, yellow, red, whatever) of the image ONLY for the UNSELECTED state, and leave the image as it is for the SELECTED state.
Also, you may need to add a tint color for the tab bar in order to apply a different color for the SELECTED state (instead of the default iOS blue color). As per your screenshot above, you are applying white color for the selected state:
EDIT:
Swift
For Image:
For Text:
You may also do by this way:
Optional:
I hope it will help you.
From here.
Each tab bar item has a title, selected image, unselected image, and a badge value.
Use the Image Tint (selectedImageTintColor) field to specify the bar item’s tint color when that tab is selected. By default, that color is blue.
In Swift 4.2:
Subclass your TabbarViewController and in ViewDidLoad put this code:
This is the simplest working solution I have