UINavigationBar的外观并不总是工作
问题描述:
我使用这个代码在我AppDelegates applicationDidFinishWorking
方法:UINavigationBar的外观并不总是工作
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes: @{
UITextAttributeTextColor: [UIColor redColor],
UITextAttributeTextShadowColor: [UIColor clearColor],
}];
这适用于第2个UIViewControllers它们推到UINavigationController的。但是在第3级,标题出现在标准颜色(白色,灰色阴影)中。
有人遇到过类似的问题吗?
更新:
没有故事板
-
林推新UIViewControllers总是这样:
UIViewController *con = [[UIViewController alloc] init]; [navigationController pushViewController:con animated:YES]; [con release];
-
我使用自定义的 'init' 的方法或不
检查 - 经过测试,还可以在p之前或之后设置标题将UIViewController用于导航堆栈
答
尝试使用图像,我使用图像并在我的所有导航中使用。 UIImage * navBackgroundImage = [UIImage imageNamed:@“MyImage”]; [[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
您使用storyboard/xib或在代码中执行所有操作? – Kuba
你在level3做什么?不推? –
重复检查第三个视图控制器。某些代码可能会更改导航栏的属性。 –