yong ho
yong ho

Reputation: 4042

How to get rid of the line on top of my button in a UIToolBar

I've created a UIToolBar and set two UIBarButtonItems 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: enter image description here

Upvotes: 0

Views: 134

Answers (1)

rmaddy
rmaddy

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

Related Questions