UIAppearance为UIPopoverController删除自定义NavBar背景 [英] UIAppearance Remove Custom NavBar Background for UIPopoverController
问题描述
我正在整合iOS 5的UIAppearance功能,为我的通用应用程序提供独特的主题。目前,我已在我的App Delegate中实现了一些代码,以便为应用程序提供自定义导航栏:
I'm in the process of incorporating iOS 5's UIAppearance feature to give my universal app a unique theme. Currently, I have implemented some code in my App Delegate to give the app custom navigation bars:
UIImage *navBarImage = [[UIImage imageNamed:@"navigationBar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(7, 7, 7, 7)];
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
这很有效,可以将所有导航栏从Apple的简单样式更改为明亮渐变。但是,我遇到的问题是它覆盖了一些我不想要它的风格。我的特殊问题是它覆盖了iPad的UIPopoverController中的导航栏背景,创造了丑陋的用户体验。请告诉我如何修复它。
This works well and changes all the navigation bars from Apple's plain style to a bright gradient. However, the problem I am having is that it is overriding some style that I don't want it too. My particular issue is that it overrides the navigation bar background in the iPad's UIPopoverController, creating an ugly user experience. Please tell me how to fix it.
编辑:请注意,这是一个通用应用程序,我通过iPad上的UIPopoverController打开图像选择器,并在上面打开模态视图iPhone / iPod。我只想删除iPad弹出窗口上navBar的自定义背景,而不是模态视图。
Please note that this is an universal app and I open the image picker through a UIPopoverController on the iPad and a modal view on the iPhone/iPod. I only want to remove the custom background for the navBar on the iPad popover, not on the modal view.
目前的样子:
How it currently looks like:
我希望它看起来像:
How I want it to look like:
谢谢提前为您提供帮助,
Guvvy
Thanks in advance for your help, Guvvy
推荐答案
尝试使用 + appearanceWhenContainedIn:
当它们包含在弹出控制器中时,从导航栏中删除背景图像自定义的方法。这样的事情:
Try using the +appearanceWhenContainedIn:
method to remove your background-image customization from navigation bars when they’re contained in popover controllers. Something like this:
[[UINavigationBar appearanceWhenContainedIn:[UIPopoverController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
从文档中不清楚是否将导航栏的背景图像设置为 nil
恢复其默认外观 - 如果不起作用,您可能必须采取相反的方法,并提供您正在使用的非弹出容器视图控制器列表 + appearanceWhenContainedIn:
。
It’s not clear from the documentation whether setting a navigation bar’s background image to nil
restores its default appearance—if that doesn’t work, you might have to take the opposite approach, and provide the list of non-popover container view controllers you’re using to +appearanceWhenContainedIn:
.
这篇关于UIAppearance为UIPopoverController删除自定义NavBar背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!