When I use the below code from a singleton, UITabBar appearance is not working completely (not changing at all), and UINavigationBar appearance is changing arbitrarily, not according to switch cases.
#pragma mark - UITabBarController Delegate
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
NSLog(@"switch");
switch ([tabBarController.viewControllers indexOfObject:viewController])
{
case 0:
[[UINavigationBar appearance] setBackgroundImage:[UIColor imageWithColor:[AppConfiguration color3]] forBarMetrics:UIBarMetricsDefault];
[[UITabBar appearance] setBarTintColor:[AppConfiguration color3]];
break;
case 1:
[[UINavigationBar appearance] setBackgroundImage:[UIColor imageWithColor:[AppConfiguration color4]] forBarMetrics:UIBarMetricsDefault];
[[UITabBar appearance] setBarTintColor:[AppConfiguration color4]];
break;
case 2:
[[UINavigationBar appearance] setBackgroundImage:[UIColor imageWithColor:[AppConfiguration color5]] forBarMetrics:UIBarMetricsDefault];
[[UITabBar appearance] setBarTintColor:[AppConfiguration color5]];
break;
default:
NSLog(@"UITabBar index: %lu", (unsigned long)[tabBarController.viewControllers indexOfObject:viewController]);
break;
}
}