Ludovic Landry
Ludovic Landry

Reputation: 11774

Change UIPopoverController color (and back button color)

I try to change the color from a UIPopoverControler on iOS 5. To do so, I use a subclass of UIPopoverBackgroundView that I assign to my popover like this:

self.popover.popoverBackgroundViewClass = [KWPopoverBackgroundView class];

My popover is now black as I defined in my KWPopoverBackgroundView class but I still have a problem with the appearance. The back button (Medals) of the navigationController inside my popover is still blue. I want everything unified in black. How do I get rid of this blue color?

enter image description here

I tried to change the tintColor of my navigationController.navigationBar but of course the popover does'nt care about that. Is there a way to fix this in iOS 5.0 ? (My app is on the AppStore, I don't want a ugly hack to fix this) Thank you.

Upvotes: 5

Views: 4464

Answers (1)

Ludovic Landry
Ludovic Landry

Reputation: 11774

Ok, I just found how to change the tint color from the UINavigationController back button (or other UIBarButtonItems) inside the UIPopoverController.

With UIPopoverBackgroundView you can only change background and arrow images. To change the other items appearance you have to use UIAppearance with something like the following.

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

black popover with black back button item

Upvotes: 12

Related Questions