iOS 7 UINavigationBar Background image hides Title view

10,597

Solution 1

Behavior of tintColor for bars has changed on iOS 7.0, please check the image below:

enter image description here

You can see that

tintColor: is the color for the interactive elements within a navigation bar including button images and titles.

barTintColor is the background color of the UINavigationBar.

For your issue: you can do the below:

navigationBar.tintColor = [UIColor whiteColor];
navigationBar.barTintColor = [UIColor colorWithRed:6.0/255.0 green:12.0/255.0 blue:19.0/255.0 alpha:1.0];

Solution 2

The default font color is black so you are probably drawing a black font on a black background. Try the following:

[[UINavigationBar appearance] setTitleTextAttributes:
                              [NSDictionary dictionaryWithObjectsAndKeys:
                              [UIColor whiteColor], NSForegroundColorAttributeName,nil]];

Solution 3

check the property extend edges on the property inspector of your view this will extend the edges from the bottom of your navigation bar to the top of your screen so your background image will be at the right place

enter image description here

check the transition guide for ios7 if you want more info about new things in ios7 https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/TransitionGuide/index.html

Share:
10,597
Krunal
Author by

Krunal

iPhone/iPad developer from Mumbai (India) and you will always find me here to help you ;)

Updated on June 26, 2022

Comments

  • Krunal
    Krunal almost 2 years

    I made iOS app, in which i want my app to compatible with iOS 7

    Problem which i am facing is, when i run my app on iOS 7, Background image of my UINavigationBar hides my titleview and back button

    screenshot here:

    -(void)viewDidLoad
    {
        [super viewDidLoad];
    
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"top.png"] forBarMetrics:UIBarMetricsDefault];
    
        self.title=@"Artist";
        self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
    
    
    }
    

    also when, i set Background image of UINavigationBar to nil it shows titleview and back button

    When i run my apps prior to iOS 7 it works properly.

    Please help. Thanks in advance.

  • Krunal
    Krunal over 10 years
    Where is extend edges on the property inspector ?
  • jonas vermeulen
    jonas vermeulen over 10 years
    i added a screenhot . you can see the option Under top bar in the category extend edges, check this option
  • Krunal
    Krunal over 10 years
    Yes i have checked both all four option which you have checked still not working. i.imgur.com/0ydD1Y8.png
  • jonas vermeulen
    jonas vermeulen over 10 years
    then i'm not sure what the solution could be, maybe this webpage can help appdesignvault.com/ios-7-update
  • Krunal
    Krunal over 10 years
    I have also wrote, if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) { self.edgesForExtendedLayout=NO; } in viewDidLoad
  • Tarek Hallak
    Tarek Hallak over 10 years
    I suggest to remove all the appearance settings you have made for your navigationBar and try the defaults first.
  • Krunal
    Krunal over 10 years
    barTintColor crashes on iOS 6
  • Tarek Hallak
    Tarek Hallak over 10 years
    It will, it is only available for iOS7, you need to check the version of iOS and use the proper attributes.
  • Krunal
    Krunal over 10 years
    I am using Image on navigationBar not color.
  • Dipu Rajak
    Dipu Rajak over 10 years
    I am using image for navigationBar as well. Those code worked for me. Best place to set the tint color will be at the time of initializing navigation bar. Suppose if you have UINavigationController *myNavController=.... myNavController.navigationBar.tintColor=[UIColor whiteColor]; ...self.navigationController.navigationBar.tintColor=[UIColo‌​r whiteColor]; overrides the color from default...