Search code examples
ios6uinavigationbar

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?


Solution

  • The workaround, which I found half a year later, is actually embarrassingly simple:

    self.navigationController.navigationBar.clipsToBounds = NO;
    

    This said, I still believe this is a bug with how Xcode 4.4/4.5 configures navigation bars in storyboards. But at least now we know how to work around it. Cheers!