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

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

    I came across this SO question when trying to get nav bars to look the same between iOS6 and iOS7.

    The answer I found worked was simply to use:

        NSMutableDictionary *titleBarAttributes = [NSMutableDictionary dictionaryWithDictionary: [[UINavigationBar appearance] titleTextAttributes]];
        [titleBarAttributes setValue:[NSNumber numberWithInt:0] forKey:UITextAttributeTextShadowOffset];
        [[UINavigationBar appearance] setTitleTextAttributes:titleBarAttributes];
    

    ie: set the shadow offset to zero.

提交回复
热议问题