I use UIAppearance
to set backgroundImage of all NavigationBar
s in my app.
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"background.png"] forBarMetrics:UIBarMetricsDefault];
At the same time I use UIPrintInteractionController
to implement a printing feature.
The problem is that printing dialog uses global appearance setting for it's navigation bar. It looks like this:
In this dialog it's not appropriately, I would like to not to use any background images here and have a system dialog.
I tried to use
[UINavigationBar appearanceWhenContainedIn:[UIPrintInteractionController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
, but app crashes with this message: UIPrintInteractionController does not conform to the UIAppearanceContainer protocol
.
The second idea was to set the backgroundImage of navigationBar to nil for UIPrintInteractionController
, for example when it gets initialized, or before it is shown (in delegate method). But UIPrintInteractionController
has no public methods to get it's navigationBar, and moreover, it inherits from NSObject
.
Is there a way to get rid of background image in navigation bar of UIPrintInteractionController
?
You can take advantage of the fact that this controller is presented in UIPopoverController which supports UIAppearance containment:
[[UINavigationBar appearanceWhenContainedIn:[UIPopoverController class], nil]