objective-c 如何在 iOS 7 上获得不透明的 UINavigationBar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19172234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get an opaque UINavigationBar on iOS 7
提问by tentmaking
Is there any way to make the UINavigationBar, targeted for iOS 7, a solid color with no translucency? I have tried setting the backgroundColor, the barTintColor, opaque, transparent/translucent, etc... and nothing works.
有什么方法可以使UINavigationBar针对 iOS 7 的 . 成为没有半透明的纯色?我试过设置 backgroundColor、barTintColor、不透明、透明/半透明等......但没有任何效果。
Anyone know how to do this?
有人知道怎么做吗?
Here are some chunks of code I have been using. Notice the properties I have set on the navigationBar. None of them, in any order or combination have worked.
这是我一直在使用的一些代码块。请注意我在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;
回答by Vadoff
Your code lists navigationController.navigationBar.translucent = YES;
您的代码列出了 navigationController.navigationBar.translucent = YES;
Set it to NO.
将其设置为否。
回答by marmikshah
To make it totally opaque u can just change the style of the navigation bar from the property section itself!
要使其完全不透明,您只需从属性部分本身更改导航栏的样式即可!




This is how it looks like when u make it black
这是当你把它变黑时的样子
回答by Nick Yap
To make all of your navigation bars opaque, you could just add UINavigationBar.appearance().translucent = falseto application:didFinishLaunchingWithOptions:
要使所有导航栏不透明,您只需添加UINavigationBar.appearance().translucent = false到application:didFinishLaunchingWithOptions:
回答by AlQaim Solutions
self.navigationController.navigationBar.isTranslucent = false

