Ben Zotto
Ben Zotto

Reputation: 71008

Best way to get a "back" nav button with the arrow icon in it?

Apple frequently uses a left arrow icon in the their navigation controller "back" button, rather than the word "back" or other text:

enter image description here

It doesn't seem possible to assign an image to this special button with the standard SDK. Am I missing something obvious? If not, what's the most effective way of achieving this? (Can it be done without Photoshopping the whole button in multiple states?)

Thanks.

Upvotes: 4

Views: 811

Answers (2)

Anomie
Anomie

Reputation: 94794

Create a UIBarButtonItem with the image and assign it as the backBarButtonItem property of your view controller's navigationItem.

Upvotes: 4

Angelo
Angelo

Reputation: 533

You can use -initWithImage:style:target:action: of UIBarButtonItem and put your image instead.

- (id)initWithImage:(UIImage *)image
              style:(UIBarButtonItemStyle)style
             target:(id)target
             action:(SEL)action

Upvotes: 1

Related Questions