UIAppearance Remove Custom NavBar Background for UIPopoverController

I am in the process of enabling the iOS 5 UIAppearance feature to give my universal app a unique theme. I have currently implemented some code in the App Delegate app to provide custom application navigation bars:

UIImage *navBarImage = [[UIImage imageNamed:@"navigationBar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(7, 7, 7, 7)]; [[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault]; 

This works well and changes all Apple’s navigation bars in the usual style to a bright gradient. However, the problem I am facing is that it redefines some style that I don't need either. My particular problem is that it overrides the background in the navigation bar of the iPad UIPopoverController, creating an ugly user experience. Please tell me how to fix it.

Edit: Please note that this is a universal application, and I open the image picker through the UIPopoverController on the iPad and the modal view on the iPhone / iPod. I just want to remove the custom background for navBar on the iPad popover, not the modal view.

What it looks like at the moment: enter image description here

How I want it to look like this: enter image description here

Thanks in advance for your help, Guvvy

+6
source share
1 answer

Try using the +appearanceWhenContainedIn: method to remove the background image settings from the navigation panels when they are contained in popover controllers. Something like that:

 [[UINavigationBar appearanceWhenContainedIn:[UIPopoverController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; 

It is not clear from the documentation whether setting the background image of the navigation bars to nil restores its default appearance - if this does not work, you may have to take the opposite approach and provide a list of controllers with youre open container using +appearanceWhenContainedIn:

+14
source

Source: https://habr.com/ru/post/919696/


All Articles