1

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

eemceebee
  • 2,656
  • 9
  • 39
  • 49
  • Is the `editButtonItem` a UIBarButtonItem? If so, is it initialized with the method `initWithBarButtonSystemItem:` or `initWithTitle:`? – Endemic May 23 '10 at 15:26
  • actually the editButtonItem is a predefined UIBarButtonItem from the UIViewController. – eemceebee May 23 '10 at 19:51

2 Answers2

2

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
  • 1,540
  • 3
  • 15
  • 21
0

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/...

Community
  • 1
  • 1
Endemic
  • 1,540
  • 11
  • 10