【问题标题】:How to get an opaque UINavigationBar on iOS 7如何在 iOS 7 上获得不透明的 UINavigationBar
【发布时间】:2013-10-10 22:06:41
【问题描述】:

有没有什么方法可以让UINavigationBar(针对 iOS 7)变成没有半透明的纯色?我已经尝试设置背景颜色、barTintColor、不透明、透明/半透明等......但没有任何效果。

有人知道怎么做吗?

这是我一直在使用的一些代码块。注意我在navigationBar 上设置的属性。它们中的任何一个,以任何顺序或组合都没有奏效。

@property (strong, nonatomic) UITabBarController *tabBarController;

testViewController = [[TestViewController alloc] init];
anotherViewController = [[AnotherViewController alloc] init];
navigationController = [[UINavigationController alloc]
                            initWithRootViewController:testViewController];

navigationController.navigationBar.barTintColor = [UIColor darkGrayColor;
navigationController.navigationBar.barStyle = UIBarStyleBlack;
navigationController.navigationBar.translucent = YES;
navigationController.navigationBar.opaque = YES;

NSArray *tabBarViewControllers = [NSArray arrayWithObjects:
                                      navigationController,
                                      anotherViewController, nil];
self.tabBarController.viewControllers = tabBarViewControllers;

【问题讨论】:

  • 贴出你设置半透明的代码。
  • 请检查编辑。谢谢。
  • 尝试将self.navigationController.navigationBar.translucent = NO; 放入您的testViewController。

标签: objective-c ios7 uinavigationbar transparency


【解决方案1】:
self.navigationController.navigationBar.isTranslucent = false

【讨论】:

    【解决方案2】:

    要使所有导航栏不透明,您只需将UINavigationBar.appearance().translucent = false 添加到application:didFinishLaunchingWithOptions:

    【讨论】:

      【解决方案3】:

      您的代码列出了 navigationController.navigationBar.translucent = YES;

      设置为否。

      【讨论】:

        【解决方案4】:

        要使其完全不透明,您只需从属性部分本身更改导航栏的样式!

        这就是你把它变黑时的样子

        【讨论】:

        • 我会尝试把它翻译成代码。我没有使用xib。谢谢。
        • 这似乎不起作用。当我将 barStyle 设置为 UIBarStyleBlack 时,我的 UITableView 项目仍然通过 UINavigationBar 显示。
        • 然后尝试去除半透明
        • 好的,我从您提供的详细信息中得到了什么。你在一个视图控制器中有一个 UINavBar 和 UITableView ,好吗?我以前遇到过这种问题,所以我为我的 UITable 视图使用了容器视图。我将容器视图放在导航栏所在的视图控制器上,并将表格视图放在容器的视图控制器中!希望这行得通!
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多