I'm presenting my view controller with the following code:
UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:sessionController];
[self presentViewController:navigation animated:YES completion:^{
}];
from within the presented view controller "viewDidLoad" method I'm attempting to set the navigation bar color with the following, but I am not successful:
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
self.navigationController.navigationBar.backgroundColor = [UIColor blackColor];
self.navigationController.view.backgroundColor = [UIColor blackColor];
UINavigationBar.appearance.backgroundColor = [UIColor blackColor];
UINavigationBar.appearance.tintColor = [UIColor blackColor];
The navigation bar color will NOT change from white. Any advice would be much appreciated.
Note: I am not using story boards or XIB files.
Try the following code to change the background color:
[self.navigationController.navigationBar setBarTintColor:[UIColor blackColor]];
[self.navigationController.navigationBar setTranslucent:NO];
The navigation controller object create when applied the color. Like this below example.
UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:sessionController];
navigation.navigationBar.tintColor = [UIColor blackColor];
navigation.navigationBar.backgroundColor = [UIColor blackColor];
navigation.navigationBar.barTintColor = [UIColor blackColor];
[self presentViewController:navigation animated:YES completion:^{
}];
And below this method all navigation controller change color.
UINavigationBar.appearance.backgroundColor = [UIColor blackColor];
UINavigationBar.appearance.tintColor = [UIColor blackColor];
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.