I am currently setting up the background image of the navigation bar of an iOS application using the UIAppearance proxy. There is a button for switching between two different modes that trigger a notification. This notification will change the background to another image using the proxy again. My problem is that this change only becomes visible when I switch to another controller and I return to it. I cannot force update the navigation bar in the controller.
I tried this in my MainTabBarController:
- (void) onAppChangedMode: (NSNotification*)notif { APP_MODE mode = (APP_MODE) [[notif object] integerValue]; // change navigation bar appearance [[UILabel appearance] setHighlightedTextColor:[UIColor redColor]]; [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:(mode == 0 ? @"navbar.png" : @"navbar2.png")] forBarMetrics:UIBarMetricsDefault]; // trying to update for (UIViewController* vc in self.viewControllers) { [vc.navigationController.navigationBar setNeedsDisplay]; } }
but nothing ... it does not work. Any idea how to achieve it?
Thanks!
Claus source share