【问题标题】:Change UIPopoverController color (and back button color)更改 UIPopoverController 颜色(和后退按钮颜色)
【发布时间】:2012-06-18 08:18:47
【问题描述】:

我尝试从 iOS 5 上的 UIPopoverControler 更改颜色。为此,我使用了 UIPopoverBackgroundView 的子类,我将其分配给我的弹出框,如下所示:

self.popover.popoverBackgroundViewClass = [KWPopoverBackgroundView class];

我的弹出框现在是黑色的,正如我在 KWPopoverBackgroundView 类中定义的那样,但我的外观仍然存在问题。我的弹出框内的导航控制器的后退按钮(奖牌)仍然是蓝色的。我希望一切都统一为黑色。如何摆脱这种蓝色?

我试图改变我的navigationController.navigationBar 的tintColor 但当然popover 并不关心这一点。 有没有办法在 iOS 5.0 中解决这个问题? (我的应用在 AppStore 上,我不想用丑陋的黑客来解决这个问题)谢谢。

【问题讨论】:

    标签: ios ipad uikit uipopovercontroller popover


    【解决方案1】:

    好的,我刚刚找到了如何从 UIPopoverController 内的 UINavigationController 后退按钮(或其他 UIBarButtonItems)更改色调颜色。

    使用 UIPopoverBackgroundView 只能更改背景和箭头图像。要更改其他项目的外观,您必须将 UIAppearance 与以下内容一起使用。

    // Set the UIBarButtonItem(s) inside UIPopoverController class to dark gray
    [[UIBarButtonItem appearanceWhenContainedIn:[UIPopoverController class], nil] 
                            setTintColor:[UIColor colorWithWhite:0.1f alpha:1.0f]];
    

    【讨论】:

    • 我搜索了多个关键字,正准备放弃并从 Google 图片搜索中找到要使用的图片。奇怪的是,正是谷歌图片搜索给我带来了这个漂亮的解决方案。感谢您用这个回答您自己的问题!