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

前端 未结 13 1473
后悔当初
后悔当初 2020-12-12 17:10

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

13条回答
  •  一整个雨季
    2020-12-12 17:32

    There are two possible solutions, the second of which is mentioned in other answers.

    1. Add a single, transparent, pixel at the bottom of your navigation bar background image, making it 45pt tall. This disables the shadows in iOS 6.
    2. Implement the following code:

      // Omit the conditional if minimum OS is iOS 6 or above
      if ([UINavigationBar instancesRespondToSelector:@selector(setShadowImage:)]) {
          [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
      }
      

    Source: Advanced Appearance Customization on iOS, @27:15

提交回复
热议问题