我的导航栏显示不清晰。

时间:2015-06-25 22:39:47

标签: ios objective-c xcode uinavigationcontroller uinavigationbar

我的导航栏显示不清晰。我的viewdid加载中有以下代码。此代码适用于其他视图控制器,但由于某种原因,此当前视图控制器仍然在顶部显示白色半透明条。不知道为什么这会在某些页面上起作用,而不是在其NSLog打印UIDeviceWhiteColorSpace 0 0,我知道这意味着清楚。导航栏上有条形按钮,我需要它们留下来,否则我只是完全隐藏了导航栏。有关为什么会发生这种情况的任何提示,或其他方式有明确的导航栏。谢谢。

self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
NSLog(@"color: %@", self.navigationController.view.backgroundColor);
NSLog(@"color: %@", self.navigationController.navigationBar.backgroundColor);

2 个答案:

答案 0 :(得分:1)

要对应用程序中的UINavigationController应用统一行为,最好在应用委托中更改其外观

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ....
    [[UINavigationBar appearance] setShadowImage:[UIImage new]];
    [[UINavigationBar appearance] setTranslucent:YES];
    [[UINavigationBar appearance] setBackgroundColor:[UIColor clearColor]];
    ...
}

答案 1 :(得分:0)

解决方案是将代码放入viewWillAppear而不是viewDidLoad。一些视图控制器需要导航栏作为完全不透明度,有些需要它清晰。总的来说,我得到了我需要的。谢谢!