Objective c ios7 UINavigationBar setTitleTextAttributes应用程序崩溃
我想为所有导航栏设置一致的标题颜色:Objective c ios7 UINavigationBar setTitleTextAttributes应用程序崩溃,objective-c,ios7,Objective C,Ios7,我想为所有导航栏设置一致的标题颜色: NSDictionary *titleAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName: MY_FONT_HERE}; [[UINavigationBar appearance] setTitleTextAttributes:titleAttributes]; 这段
NSDictionary *titleAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],
NSFontAttributeName: MY_FONT_HERE};
[[UINavigationBar appearance] setTitleTextAttributes:titleAttributes];
这段代码在iOS6中工作,但在ios7中崩溃
崩溃消息很奇怪:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [__NSCFConstantString pointSize]: unrecognized selector sent to instance 0x107c34'
我猜我的字体是字符串值,而它应该是UIFont。不要将字符串传递给属性,而是使用
[UIFont-fontWithName:MY\u-font\u HERE]
初始化字体,我猜MY\u-font\u HERE是一个字符串值,而它应该是UIFont。不要将字符串传递给属性,而是使用[UIFont-fontWithName:MY\u font\u HERE]
初始化字体