简体   繁体   中英

iOS 6 Navigation Bar Color in Xcode 5

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.

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.

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.

看起来我需要做的是检查设备是否运行低于iOS 7的版本,然后设置

[[[self navigationController] navigationBar] setTintColor:[UIColor blackColor]];

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...

UIBarStyleBlackOpaque is deprecated.

Use UIBarStyleBlack instead.

Alternatively in iOS 7 you can set the barTintColor property to black.

for :- iOS 7

// set tint color in io s6
[[[self navigationController] navigationBar] setBarTintColor:[UIColor blackColor]];

for :- 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM