I have a basic master-detail app. Depending on the item that is selected in the master list, I'd like to set the tintColor
of the navigation bar in the details view only.
I set the tint color like so: self.navigationController.navigationBar.tintColor = detailTintColor;
in viewWillAppear:
of the details controller.
However, this also changes the color of the master controller's navigation bar to yellow (should remain red), which is visible as a flickering during the transition animation. I assume because there is only one navigation bar instance.
Here a screenshot to illustrate the problem:
In iOS 8 we set tint color by this :-
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
why not resetting to original color when view disapperars?
-(void)viewWillDisappear:(BOOL)animated {
self.navigationController.navigationBar.tintColor = yourSavedColor;
[super viewWillDisappear:animated];
}
You only have to change the tint color of the UINavigationBar
in the Details UINavigationController
in Storyboard:
Working sample:
You could use the UIAppearance
API to obtain the same result by subclassing UINavigationController
, and setting the details controller to be that custom class. Then, using UIAppearance API, set the UINavigationBar
tint color:
[[UINavigationBar appearanceWhenContainedIn:[DetailNavigationController class], nil] setTintColor:[UIColor redColor]];
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