如何在iOS 7上获得不透明的UINavigationBar

ten*_*ing 29 transparency objective-c uinavigationbar ios7

是否有任何方法可以使UINavigationBariOS 7的目标成为一种没有半透明效果的纯色?我试过设置backgroundColor,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;
Run Code Online (Sandbox Code Playgroud)

Vad*_*off 56

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

将其设置为NO.


mar*_*hah 9

为了使它完全不透明,您只需从属性部分本身更改导航栏的样式即可!

只需将样式设置为黑色!

当你把它变成黑色时,这就是它的样子


Nic*_*Yap 7

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