Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable the navigation bar shadow in iOS 6 for navigation bars with custom background images?

It seems in iOS 6, a drop shadow is automatically added to the navigation bar even when you set a custom background image. I'm pretty sure this wasn't the case with iOS 5 as when I test the same code in the iOS 5 and 6 sim, the shadow appears in iOS 6 but not 5.

Does anyone know anything about this? Or how to enable/disable it?

like image 834
Dom Chapman Avatar asked Jun 18 '12 13:06

Dom Chapman


People also ask

Can you change iPhone navigation bar?

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.

How do I change my Apple navigation bar?

On your Mac, use Dock & Menu Bar System Preferences to change the appearance of the Dock, and to select items to show in the menu bar and in Control Center. To change these preferences, choose Apple menu > System Preferences, then click Dock & Menu Bar .


1 Answers

Place this in your AppDelegate

[[UINavigationBar appearance] setShadowImage:[UIImage new]]; // is IOS 7 and later [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; 

This is what did it for me. Hope it helps!

Swift version with updates from comments

    UINavigationBar.appearance().shadowImage = UIImage()     UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: .Default) 
like image 104
Kevin Fernandes Avatar answered Sep 21 '22 21:09

Kevin Fernandes