Xcode 5 中的 iOS 6 导航栏颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19060249/
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
iOS 6 Navigation Bar Color in Xcode 5
提问by Kamaros
I'd spent a few months developing an application for iOS 6 when I updated to Xcode 5. I updated the application to fit with the iOS 7 style, when I decided to run the application again on iOS 6.1. I found that my previously black navigation bar had turned white.
当我更新到 Xcode 5 时,我花了几个月的时间为 iOS 6 开发应用程序。当我决定在 iOS 6.1 上再次运行应用程序时,我更新了应用程序以适应 iOS 7 风格。我发现我以前的黑色导航栏变成了白色。
I swapped my storyboard to be viewed as "iOS 6.1 and Earlier", and found that the color of the navigation bar was white, even though it was set to "Opaque Black Navigation Bar" in the simulated metrics.
我将我的故事板交换为“iOS 6.1 及更早版本”,发现导航栏的颜色为白色,即使它在模拟指标中设置为“不透明黑色导航栏”。
Any ideas on how to fix this? I've already tried manually setting the child view top bars to "Opaque Black Navigation Bar" as well. This changes the color of the navigation bar for the child to appear black on the storyboard, but has no effect on the application when run on the simulator.
有想法该怎么解决这个吗?我已经尝试手动将子视图顶部栏设置为“不透明黑色导航栏”。这会改变孩子导航栏的颜色,使其在情节提要上显示为黑色,但在模拟器上运行时对应用程序没有影响。
回答by Kamaros
Looks like what I needed to do was check if the device was running a version less than iOS 7, then set
看起来我需要做的是检查设备是否运行低于 iOS 7 的版本,然后设置
[[[self navigationController] navigationBar] setTintColor:[UIColor blackColor]];
回答by Arkady
For setting the color of the navigation bar, I did the following:
为了设置导航栏的颜色,我做了以下事情:
if([self.navigationController.navigationBar respondsToSelector:@selector(barTintColor)])
{
// iOS7
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:236.0/255.0 green:139.0/255.0 blue:23.0/255.0 alpha:1.0];
}
else
{
// older
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:236.0/255.0 green:139.0/255.0 blue:23.0/255.0 alpha:1.0];
}
Hopefully somebody will find it helpful...
希望有人会发现它有帮助......
回答by Gabriele Petronella
UIBarStyleBlackOpaque
is deprecated.
UIBarStyleBlackOpaque
已弃用。
Use UIBarStyleBlack
instead.
使用UIBarStyleBlack
来代替。
Alternatively in iOS 7 you can set the barTintColor
property to black.
或者,在 iOS 7 中,您可以将该barTintColor
属性设置为黑色。
回答by Ashish
for :- iOS 7
适用于:- iOS 7
// set tint color in io s6
[[[self navigationController] navigationBar] setBarTintColor:[UIColor blackColor]];
for :- iOS 7
适用于:- iOS 7
// set translucent property to NO in iOS 7
self.navigationController.navigationBar.translucent=NO;
// set Bar tint color
[[[self navigationController] navigationBar] setTintColor:[UIColor blackColor]];
// But I would recommend Use Images instead of color.
for iOS 6 :- 320 X 44 size of Image
for iOS 7 :- 320 X 64 size of Image
对于 iOS 6 :- 320 X 44 大小的图像
对于 iOS 7 :- 320 X 64 大小的图像