I want to convert my current project from iOS 6 to iOS 7. In iOS 6 my project is working fine, but in iOS 7 navigation bar image is not showing properly.
I used this code snippet for iOS 6,
UIImage *imgNav = [UIImage imageNamed:@"navigation.png"];
self.navigationController.navigationBar.frame = CGRectMake(0, 0, 320, 44);
[self.navigationController.navigationBar setBackgroundImage:imgNav forBarMetrics:
UIBarMetricsDefault];
How can I set the navigation bar image in iOS 7?
A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.
From Settings, tap Display, and then tap Navigation bar. Make sure Buttons is selected, and then you can choose your desired button setup at the bottom of the screen. Note: This option will also affect the location you swipe when using Swipe gestures.
Go to the ViewController. swift file and add the ViewDidAppear method. a nav helper variable which saves typing. the Navigation Bar Style is set to black and the tint color is set to yellow, this will change the bar button items to yellow.
On iPhone tab bars remain 49 points tall in portrait and 32 points tall in landscape. iPhone X added extra height for the Home Bar to toolbars and tab bars and their sizes are unchanged from iOS 11: 83 points tall in portrait and 53 points tall in landscape.
Try Adding the below code in AppDelegate
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigation.png"]
forBarMetrics:UIBarMetricsDefault];
This is the Swift Version:
UINavigationBar.appearance().setBackgroundImage(UIImage.init(named: "navigation.png"), forBarMetrics: UIBarMetrics.Default)
Swift 3 version :
UINavigationBar.appearance().setBackgroundImage(UIImage.init(named: "logo-dark.png"), for: UIBarMetrics.default)
For iOS 7:
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With