'How do you dynamically update the color of a UITabBar from within the app

Once the app has launched, if I want to allow a user to change the tint color of the UITabBar (or NavigationController) how do I do that ?

Is there a refresh for a TabBar?



Solution 1:[1]

It seems that the code that works in the AppDelegate (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method:

[[UITabBar appearance] setTintColor: tintColorOfImages];
[[UITabBar appearance] setBarTintColor: backgroundColorOfTabBar];

doesn't work after that. However, you can make it change from any ViewController by calling:

[[[self tabBarController] tabBar] setTintColor: tintColorOfImages];
[[[self tabBarController] tabBar] setBarTintColor: backgroundColorOfTabBar];

Perhaps, it's a bug...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Al.