Question

The app I'm working on has a customized nav bar. In my AppDelegate.m I have done the following:

  • setBackgroundImage has replaced the default color of the Nav Bar with one of my own .png images;
  • setTitleTextAttributes: has been set to white;
  • setTintColor: has been set to white;

    - (void)customizeUserInterface {
        [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navBar"] forBarMetrics:UIBarMetricsDefault];
        [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, nil]];
        [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    }
    

Everything looks just fine in iOS 7, but on devices that run iOS 6 the Nav Bar buttons are white on white, because while the tint color changes the text of the button in iOS 7 (because that's all buttons are in iOS 7 - text), in iOS 6 setting tint color adjusts the background of the button, and the text remains white. So in iOS 6, the nav bar buttons are white with white text.

I rather like how my tables look in iOS 7, and would rather not change it just because backwards compatibility with iOS 6 is not cooperating.

Does anyone have a solution to this issue. Is there a way to programmatically change either the background color of the Nav Bar round rec buttons or just the text within the round rec buttons - all while not changing the appearance in iOS 7?

Or is there are way to set these changes conditionally? In other words, can I programmatically set the custom Nav Bar to appear only for devices with iOS 7+, and use the default for all iOS versions before that?

Or is there something else clever out there that I'm not thinking of?

Thanks!

Was it helpful?

Solution

Hey that's really possible to control your stuff programmatically. You have your ways to do it in ios7 & definitely you have done it for ios6.

Here is the link to check version.

Now you can do things conditionally.

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top