【问题标题】:My Navigation Bar will not appear clear.我的导航栏将不清晰。
【发布时间】:2015-06-25 22:39:47
【问题描述】:

我的导航栏将不清晰。我的 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);

【问题讨论】:

    标签: ios objective-c xcode uinavigationcontroller uinavigationbar


    【解决方案1】:

    要将统一的行为应用于整个应用程序中的UINavigationController,最好在应用程序委托中更改其外观一次

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2014-09-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-21
        • 1970-01-01
        相关资源
        最近更新 更多