I'm trying to add a custom button (shape and color) to my UIToolBar, but it comes out much differently than it should.
What button looks like:
What it looks like in the bar:
Here's the code I used to add it:
UIImage *backButtonImage = [UIImage imageNamed:@"back-button.png"];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:backButtonImage style:UIBarButtonItemStylePlain target:self action:@selector(backButtonTapped)];
[toolBarItems addObject:backButton];
What exactly am I doing wrong here?
Try using initWithCustomView:
instead of the other initialization method
So you should first create a UIButton with the custom image and selector you want and then use this piece of code
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:yourButton];
[toolBarItems addObject:backButton];