I’m having a problem when I try to change a UINavigationBar’s “back” button custom icon. To achieve such a thing, I’m using the following code:
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem* leftBtn;
UIImage* botonVolverImg = [UIImage imageNamed:@"boton_volver.png"];
leftBtn = self.navigationItem.leftBarButtonItem;
leftBtn.image = botonVolverImg;
}
But, when the view appears, you see this:
a busy cat http://www.timotteo.com.ar/boton.png
(You can see that the old button still appears at the back, plus the image I chose looks a bit streched)
I’ve been changing the imageInsets property, but that doesn’t seem to work. I’ve also been reading the forum around, but couldn´t find the exact solution.
Any suggestions are welcomed!
To supplement Mark’s answer, if your customer is requiring you to support iOS 4, you could create a
UIButtonthat looks exactly how your customer wants it to (ie, just that image), and then useUIBarButton‘sinitWithCustomViewmethod to create your own back button. You can then have that button triggerpopViewControlleror whatever appropriate action you need.