2

I want to set a UINavigationItem's title such that it displays a 2 line title with both lines in a smaller font than normal. I've definitely seen this effect on other apps such as Mail, but I can't figure out how to get it to work.

I tried setting a prompt, that's definitely not what I want, I want the Nav Bar to stay the same height but have the text get smaller and allow two lines.

Is this possible by default or do I need my own custom view to achieve it?

Nektarios
  • 10,173
  • 8
  • 63
  • 93
  • 1
    Possible duplicate of [Multiline Navigationbar Title](http://stackoverflow.com/questions/34298383/multiline-navigationbar-title) – Bill Mar 14 '17 at 18:43

2 Answers2

2

You can set titleView to a custom view, for example a UILabel with the desired font. To make it a 2-line label, make sure you set numberOfLines to 2.

Rob Lourens
  • 15,081
  • 5
  • 76
  • 91
  • Right, 0 will let the UILabel have any number of lines. I was just thinking that since I think that's the only thing I've used it for myself... – Rob Lourens Jul 18 '11 at 12:39
1

Other than setting the Prompt, what you are looking for is a custom navigationBar with a UILabel setting the numberOfLines property to 2. Alternatively, you can use 2 UILabel's.

WrightsCS
  • 50,551
  • 22
  • 134
  • 186
  • @RobLourens and @WrightsCS how do I know what to set the frame to? (For example, this has to work on all iOS devices etc..). Also, the font and color looks completely different .. – Nektarios Jul 18 '11 at 03:29
  • Set your `AutoResizingMasks`. – WrightsCS Jul 18 '11 at 03:31