Rahul
Rahul

Reputation: 961

How can I set image in background of navigation bar in Objective-C

How we set image in navigation bar in iPhone?

self.navigationController.navigationBar.tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"banner.png"]];`

Upvotes: 0

Views: 448

Answers (2)

Chris Grant
Chris Grant

Reputation: 2385

This won't work in iOS 5 correctly. See this answer for how to implement this in a way that works in iOS5 and previous versions. Custom nav bar styling - iOS

This is a much better way to do things and ensures your app will work in multiple versions of iOS.

Upvotes: 1

Aravindhan
Aravindhan

Reputation: 15628

UIImage *image = [UIImage imageNamed:@"yourImage.png"];
self.navigationItem.titleView = [[[UIImageView alloc] initWithImage:image] autorelease];

This puts the image in your navigation bar title.

Upvotes: 0

Related Questions