0

I like to use the default size of UINavigationBar.

However, sometimes the title is too long and I want the font size to get reduced appropiately.

How would I do so?

I suppose, first I need to find out the size of the titleView first. I think that can be done.

Then I need to call a function that will tell me the appropriate font size.

Then I would need to specify the font with that size WITHOUT changing the font name for that UINavigationBar.

Anyone knows how to do any of those (doesn't need to be all).

user4951
  • 32,206
  • 53
  • 172
  • 282

1 Answers1

1

You need to set the titleTextAttributes property of the UINavigationBar. You can get the font size and font type from the same property and adjust or change the font size and font type depending on ur requirement.

Check out the documentation for more details on the same.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html

Robin
  • 10,011
  • 5
  • 49
  • 75
  • and how to get the right font size? Is there fontThatFit kind of function? – user4951 Nov 21 '12 at 05:31
  • Well that cloud be really tricky, may be you can set the minimum font size. You can check out this link for getting the size may be you can iterate it to get the right font size. http://stackoverflow.com/questions/1435544/measuring-the-pixel-width-of-a-string-in-objective-c – Robin Nov 21 '12 at 06:08