mkto
mkto

Reputation: 4665

ios7 UINavigationBar setTitleTextAttributes crashes app

I wanted to set a consistent title colors for all my navigation bars:

NSDictionary *titleAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],
                                  NSFontAttributeName: MY_FONT_HERE};
[[UINavigationBar appearance] setTitleTextAttributes:titleAttributes];

This piece of code work in iOS6 but CRASH in ios7.

The crash message is bizarre:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-                 [__NSCFConstantString pointSize]: unrecognized selector sent to instance 0x107c34'

Upvotes: 1

Views: 3434

Answers (1)

Patrick Goley
Patrick Goley

Reputation: 5417

I'm guessing that MY_FONT_HERE is a string value, when it should be a UIFont. Instead of passing in the string to the attributes, initialize the font with [UIFont fontWithName:MY_FONT_HERE].

Upvotes: 1

Related Questions