Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When does the UINavigationBar shadow show? (iOS 6)

I am using a navigation bar with a custom background image. When I wanted to add a custom shadow image, I was surprised to find that even the default shadow image is not visible.

iOS 6 introduced an automatic drop shadow on UINavigationBars, which I expected to see. The example project from http://www.raywenderlich.com/21703/user-interface-customization-in-ios-6 demonstrates this.

However, creating a new project from Xcode’s Master-Detail template does not show the shadow.

When exactly is the shadow shown, and when is it not?

like image 658
Yang Meyer Avatar asked Dec 27 '25 16:12

Yang Meyer


2 Answers

IOS 6 automatic drop shadow is shown by default. If you want to disable/hide this shadow you can try this:

[[UINavigationBar appearance]setShadowImage:[[UIImage alloc] init]];

What I have noticed is that, if I copy/paste a viewController from one project to a new one, the UINavigationBar shadow (sometimes) it's not shown. Replacing the copied viewController with a new one solves the problem... (maybe your case)

like image 103
Azpiri Avatar answered Dec 31 '25 17:12

Azpiri


I had the same problem on a project upgraded from iOS5, but only on navigation controllers inserted in the pre-iOS6 Xcode versions. Removing them and replacing them with new ones in the most recent version of Xcode (4.6) fixed the problem.

like image 44
Engin Kurutepe Avatar answered Dec 31 '25 18:12

Engin Kurutepe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!