I used the code below to change the background color of navigationbar
- (void)viewDidLoad
{
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithHexString:@"6cd3c5"]];
[super viewDidLoad];
}
the bar background color does not change immediately, I have to pushViewController:someViewController
and go back, the color can change.
Your comment welcome
Try this:
[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithHexString:@"6cd3c5"]];
[self.navigationController.navigationBar setTranslucent:NO];
Read this for more clarification.
appearance
is used for the future appearance. if you want to appearance then use before the view load.
else use
[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithHexString:@"6cd3c5"]];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.