Illep
Illep

Reputation: 16851

How to add an image on UINavigationBar

How do i add a small image on a UINavigationBar ? It should display in front of the title. Its small and 40X40 pixel in size.

noteL: I don't want to add an image to the background to add this tiny image. Furthermore this should work for both iOS4 and 5

Upvotes: 0

Views: 492

Answers (1)

Andre Cytryn
Andre Cytryn

Reputation: 2705

On a Navigation bar you can set both right and left buttons like this:

UIImage * myIcon = [UIImage imageNamed:@"icon.png"];

[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithImage:myIcon
    style:UIBarButtonItemStyleBordered target:self action:@selector(someAction:)]];

To the right button just message setRightBarButtonItem

Upvotes: 1

Related Questions