Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using global Tint color as UINavigationBars backgroundColor

i need to set the UINavigationBars background color to the same value as my apps global tint color.

problem here is that now all buttons in my navigation bar are the same color as its background. i now could change all UIBarButtons text color to white but this would be totally unusable. using the UIAppearance API doesn't seem to be a better way. after setting the text color of UIBarButton items to white, f.e the back arrows of the back button in my UINavigationBar are still painted with the global tint color.

also if i change the global tint color to white i loose all the flexibility that the global tint color gives us (also my text indicator would now be white and would not be seen on a white background)

what i want:

enter image description here

what i get using blue as global tint color

enter image description here

what i get when using blue as global tint color and setting uibarbutton items text color to white (see the back button - it should be white as well)

enter image description here

what is the recommended way to fix this problem?

like image 887
choise Avatar asked Jan 11 '23 18:01

choise


1 Answers

I recommend that you do this:

UINavigationBar *navigationBar      = [UINavigationBar appearance];
navigationBar.tintColor             = [UIColor whiteColor];

Place this code in the didFinishLaunchingWithOptions: method in the AppDelegate.

For clarification as you are obviously not very experienced with this:

barTintColor is the property that would change the bar colour. tintColor changes the colour of interactive objects (such as the UIBarButtonItems)

like image 177
Infinity James Avatar answered Jan 29 '23 04:01

Infinity James