我有一个相当简单的应用程序UITableViewController
和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;
}
在我的OverviewTableViewController
中,我尝试为这样的导航栏设置颜色,但似乎无法正常工作
self.navigationController.navigationBar.tintColor = [UIColor blueColor];
self.navigationController.navigationBar.translucent = TRUE;
我知道我可以在didFinishLaunchingWithOptions
这样做:
nav.navigationBar.tintColor = [UIColor blueColor];
nav.navigationBar.barTintColor = [UIColor blueColor];
nav.navigationBar.translucent = YES;
我如何在UITableViewController
?
答案 0 :(得分:2)
在OverviewTableViewController
的viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
UIColor *bg = [UIColor blueColor];
[self.navigationController.navigationBar setBarTintColor:bg];
[self.navigationController.navigationBar setTranslucent:YES];
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlack]
}
答案 1 :(得分:0)
在OverviewTableViewController
中,您可以使用self.navigationController
来引用navigationController。
所以,你可以使用下面的代码。
UINavigationController *nav = self.navigationController;
nav.navigationBar.tintColor = [UIColor blueColor];
nav.navigationBar.barTintColor = [UIColor blueColor];
nav.navigationBar.translucent = YES;