1

I use custom image for my navigation bar buttons using the following code, that allows me to make custom add button. I want to be able to do the same for the edit button item.

UIImage *image=[UIImage imageNamed:@"Plus.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.bounds = CGRectMake( 0, 0, image.size.width, image.size.height );    
[button setBackgroundImage:image forState:UIControlStateNormal];
[button addTarget:self action:@selector(add) forControlEvents:UIControlEventTouchUpInside];    
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.rightBarButtonItem = barButtonItem;
[barButtonItem release];

self.navigationItem.leftBarButtonItem = self.editButtonItem;

I'm doing this because I want to change the button text color.I would appreciate your help,

Sarah

Sarah
  • 1,595
  • 3
  • 25
  • 34

1 Answers1

2

You can customize the edit button in the same way you can customize any other navigation control button, for example...

self.editButtonItem.style = UIBarButtonItemStyleBordered;
self.editButtonItem.title = @"Custom";
self.navigationItem.rightBarButtonItem = self.editButtonItem;

Unfortunately changing the text colour is not as easy as setting a 'color' property, since that property doesn't exist (again this applies to all navigation control buttons). It is however possible using a label as described in the following post...

iPhone Navigation Bar Title text color

Community
  • 1
  • 1
Oliver Pearmain
  • 19,885
  • 13
  • 86
  • 90