Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 392
Ludovic Landry Avatar asked Jun 18 '12 08:06

Ludovic Landry


1 Answers

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

like image 54
Ludovic Landry Avatar answered Sep 28 '22 15:09

Ludovic Landry