Reputation: 4042
I've created a UIToolBar
and set two UIBarButtonItem
s and then assigned this toolbar to self.navigationItem.rightBarButtonItem
.
Everything works perfectly except there is a line on top of my buttons.
The code:
UIBarButtonItem *addItem = [[UIBarButtonItem alloc] initWithTitle:@"Add"
style:UIBarButtonItemStylePlain
target:self
action:@selector(addNewRow:)];
UIBarButtonItem *editItem = [[UIBarButtonItem alloc] initWithTitle:@"Edit"
style:UIBarButtonItemStylePlain
target:self
action:@selector(editRow:)];
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
[toolBar setItems:@[addItem, editItem]];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:toolBar];
Please see my pic:
Upvotes: 0
Views: 134
Reputation: 318824
You get rid of the line by getting rid of the toolbar.
UIBarButtonItem *addItem = [[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStylePlain target:self action:@selector(addNewRow:)];
UIBarButtonItem *editItem = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStylePlain target:self action:@selector(editRow:)];
self.navigationItem.rightBarButtonItems = @[ addItem, editItem ];
Upvotes: 2