在我的 AppDelegate 我有以下代码:
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController *itemsNavigationController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
如何将 UIVNagigationBar 的背景颜色设置为绿色?
如果我做:
[self.navigationController.navigationBar setTintColor:[UIColor greenColor]];
从 viewController1 来看,这没有效果。
提前致谢!
更新:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"MyTitle", @"");
[self.navigationController.navigationBar setTintColor:[UIColor greenColor]];
[self.parentViewController.navigationController.navigationBar setTintColor:[UIColor greenColor]];
}
return self;
}
两者都没有影响