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

前端 未结 13 1525
后悔当初
后悔当初 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:40

    Setting the shadowImage to a null image does work, however, the way the solution is presented results in adding a property if the OS is earlier than iOS 6.

    A better way to do something that is dependent on the existence of a property or method is:

    if ([self.navigationController.navigationBar
    respondsToSelector:@selector(shadowImage)]) {
    self.navigationController.navigationBar.shadowImage = [[[UIImage alloc] init] autorelease];
    }
    

提交回复
热议问题