Reputation: 9722
I have a fairly simple application with a UITableViewController
and a UINavigationController
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
OverviewTableViewController *overview = [[OverviewTableViewController alloc] initWithNibName:@"OverviewTableViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:overview];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
In my OverviewTableViewController
I tried setting a color for the navigation bar like this, but it doesn't seem to work
self.navigationController.navigationBar.tintColor = [UIColor blueColor];
self.navigationController.navigationBar.translucent = TRUE;
I know I can do it in didFinishLaunchingWithOptions
like this:
nav.navigationBar.tintColor = [UIColor blueColor];
nav.navigationBar.barTintColor = [UIColor blueColor];
nav.navigationBar.translucent = YES;
How can I do this in my UITableViewController
?
Upvotes: 1
Views: 1585
Reputation: 146
In your OverviewTableViewController
's viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
UIColor *bg = [UIColor blueColor];
[self.navigationController.navigationBar setBarTintColor:bg];
[self.navigationController.navigationBar setTranslucent:YES];
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlack]
}
Upvotes: 2
Reputation: 109
In your OverviewTableViewController
, you can refer to the navigationController using self.navigationController
.
So, you can do with the code below.
UINavigationController *nav = self.navigationController;
nav.navigationBar.tintColor = [UIColor blueColor];
nav.navigationBar.barTintColor = [UIColor blueColor];
nav.navigationBar.translucent = YES;
Upvotes: 0