I want to disable the border around iPhone SDK’s add button, so it’s just the “+” button (no black bg):
This seems to be a simple task when it’s located in the toolbar, but not when it’s located in the UINavigationBar. Anyways, if anyone knows how, or if it’s even possible, then please share! Here’s my current code in my RootViewController.m:
self.title = @"Code Master";
addButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self action:@selector(addButtonClicked:)];
self.navigationItem.rightBarButtonItem = addButton;
EDIT
@Dee so your code works great, displays exactly what I want! There is another problem now that I’ll explain:
Edit Button: Left side of UINavigationBar
Done Button: Left side of UINavigationBar (hidden); when the Edit button is clicked, it replaces the Edit Button with this “Done” button
Plus Button: Right side of UINavigationBar; hides when in “edit mode“, shows when in “normal mode (when Done button is not visible)“
So basically my problem now is that whenever I click Edit, then Done, the plus button doesn’t return from hiding. I’m using your exact code and it worked with my previous code. I’m pretty sure that it’s because in your code, theres nothing labelling it “addButton”. Here’s the code later on in my main file:
-(void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:YES];
if (editing)
{
self.navigationItem.rightBarButtonItem = nil;
}
else
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"Plus.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(addButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0, 0, 50, 29)];
UIBarButtonItem *barBtn = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.rightBarButtonItem = barBtn;
[barBtn release];
}
[self.tableView reloadData];
}
Create “+” image and set it to button & give that button to UIBarButtonItem like this: