I keep reading to change the default color on a navigationbar i just need to update the first method in the appdelegate to this
self.window.rootViewController.navigationController.navigationBar.tintColor = [UIColor whiteColor];
but it doesn't seem to work, so I tried setting it in the viewDidLoad method of the firstview also:
self.parentViewController.navigationController.navigationBar.tintColor = [UIColor whiteColor];
This didn't work either. How can I change this?
You don't need to have root access to change the navigation bar color. You just need to download a free customization app known as the Navbar app which is available on the Google Play Store.
Don't use self.parentViewController
, but self
:
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
When iphone 5 come we have to set both device type. So use this
if([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
//iOS 5 new UINavigationBar custom background
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbg_ForiPhone5_Imagename.png"] forBarMetrics: UIBarMetricsDefault];
} else {
[self.navigationController.navigationBar insertSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navbg_ForOtherIphone_Imagename.png"]] atIndex:0];
}
In IOS7 you can try this:
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
You can follow these steps:
I created a new UINavigationController
for example UIDemoNavController
resulting in:
- (void)viewDidLoad{
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
[super viewDidLoad];
}
This is the full demo class:
#import "UIDemoNavController.h"
@interface UIDemoNavController()
@end
@implementation UIDemoNavController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {}
return self;
}
- (void)viewDidLoad{
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning{
[super didReceiveMemoryWarning];
}
@end
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