views:

217

answers:

2

Hi

I have a UITableViewController where I added a "editButtonItem" in the navigation bar :

self.navigationItem.leftBarButtonItem = self.editButtonItem;

No magic here, but I try to define the color (background and foreground/textcolor) of this button.

I read in the Apple forum somewhere that the button changes the color if I change the navigationbar to the same color, well despite the fact that I do not get this to work either (for testing) I do not want to touch the navigationbr itself, just the button.

Since this button is already predefined I am not sure how to handle this. Do I need to overwrite the button with my own definition or can I just simply apply a new style (if so how ?)

Thx

A: 

The only way I can find to make a UIBarButtonItem with a different color is to use a custom view and the initWithCustomView: method. Predefined buttons and those created using initWithTitle:target:action: cannot change their background color.

Take a look at this SO question: UIBarButtonItem with color?

These links might also help:
http://www.iphonedevsdk.com/...
http://www.insanelymac.com/...

Endemic
+2  A: 

If everything fails, you can tint the bar in the viewDidLoad of your childViewController

[self.navigationController.navigationBar setTintColor:[UIColor colorWithHue:50 saturation:50 brightness:.2 alpha:.5]];
elementsense