10

I'd like to add a logo to the left of my title on my navigation bar. The title property seems to only take an NSString. What's the best way to add an image to the navigation bar?

2
  • Just curious so I can learn to avoid the same deficit in the future, but why did my question get marked down? Nov 30, 2008 at 2:41
  • I's be curious to see also. Seems like a reasonable, if narrow, question.
    – Darrel
    Nov 30, 2008 at 2:45

3 Answers 3

24

You can replace the title view with an image like this:

navigationItem.titleView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"title_bar.png"]];   
2
  • 7
    Correct; minor nitpick, this has a memory leak--be sure to autorelease the UIImageView.
    – Adam Ernst
    Nov 30, 2008 at 3:58
  • 4
    Anyone know the maximum and ideal dimensions for this view?
    – mxcl
    Nov 17, 2010 at 18:24
2

Set UINavigationItem.titleView to a custom view (or just a straight UIImageView).

0

You can customize navigationItem.titleView, class of UIView

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.