Colors and buttons change behavior when tinting iPhone navigationBar
-
19-09-2019 - |
Question
I was wondering why everything stops behaving as it should when I do something like this:
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
All my buttons on the navigationBar are now black regardless of style, like this one below, it should turn up as a blue button:
UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleDone target:self action:@selector(editTrip)];
It does not, it is just black.
The slight change/effect in the button when tapped is also gone?
Is there a way to change the color of the navigationBar and maybe even the UIbarButtonItems without somehow ruining standard behavior?
This is really strange. I just checked with the Apple "Remote" app, it has the black navigation bar and a blue "Done" button for leaving the "help" section.
Do I really have to build everything custom to achieve this?
Thanks for any help given:)
Solution
In Interface Builder, change the Style of the Navigation Bar to Black Opaque or Black Translucent and leave the tint alone. This will give you a black bar with the standard blue buttons.
I'm sure the way to do this in code without Interface Builder, is by setting the barStyle
property to UIBarStyleBlack
or UIBarStyleBlackTranslucent
, but I haven't done it that way.