iOS 7 UINavigationBar Background image hides Title view
Solution 1
Behavior of tintColor
for bars has changed on iOS 7.0, please check the image below:
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
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
Krunal
iPhone/iPad developer from Mumbai (India) and you will always find me here to help you ;)
Updated on June 26, 2022Comments
-
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 mytitleview
andback button
:
-(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 showstitleview
andback button
When i run my apps prior to iOS 7 it works properly.
Please help. Thanks in advance.
-
Krunal over 10 yearsWhere is extend edges on the property inspector ?
-
jonas vermeulen over 10 yearsi added a screenhot . you can see the option Under top bar in the category extend edges, check this option
-
Krunal over 10 yearsYes i have checked both all four option which you have checked still not working. i.imgur.com/0ydD1Y8.png
-
jonas vermeulen over 10 yearsthen i'm not sure what the solution could be, maybe this webpage can help appdesignvault.com/ios-7-update
-
Krunal over 10 yearsI have also wrote,
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) { self.edgesForExtendedLayout=NO; }
in viewDidLoad -
Tarek Hallak over 10 yearsI suggest to remove all the appearance settings you have made for your navigationBar and try the defaults first.
-
Krunal over 10 years
barTintColor
crashes on iOS 6 -
Tarek Hallak over 10 yearsIt will, it is only available for iOS7, you need to check the version of iOS and use the proper attributes.
-
Krunal over 10 yearsI am using Image on navigationBar not color.
-
Dipu Rajak over 10 yearsI 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=[UIColor whiteColor]; overrides the color from default...