I have been using the code below to change the navigation bar of ALL of my views:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIImage *gradientImage44 = [[UIImage imageNamed:@"clear_navigation_bar_texture_44"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:gradientImage44 forBarMetrics:UIBarMetricsDefault];
}
but I now want the navigation bar to be able to change to a different image that the user chooses based the ‘theme’ they want the app to be. Problem is, I can’t put that code in here because it would only work when the app is loaded. So, I thought of making the code a seperate method and calling it in the didFinishLaunching… method and the viewController method that I call when the user changes the ‘theme.’ My question is then, how would I do this, or is there a better way of doing it?
thanks!
You don’t have to set the theme in the app delegate; you can do it anywhere you want (and you can even make it interactive). The only thing you need to be aware of is that attributes set via
UIAppearancewill only be instantiated with new views. If you have existing views that need updating, you need to do that manually. For example: