ios7 UINavigationBar setTitleTextAttributes崩溃应用程序 [英] ios7 UINavigationBar setTitleTextAttributes crashes app
本文介绍了ios7 UINavigationBar setTitleTextAttributes崩溃应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为所有导航栏设置一致的标题颜色:
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];
此代码在iOS6中工作,但在ios7中工作。
This piece of code work in iOS6 but CRASH in ios7.
崩溃消息很奇怪:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [__NSCFConstantString pointSize]: unrecognized selector sent to instance 0x107c34'
推荐答案
我猜猜MY_FONT_HERE是一个字符串值,它应该是UIFont。不是将字符串传递给属性,而是使用 [UIFont fontWithName:MY_FONT_HERE]
初始化字体。
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]
.
这篇关于ios7 UINavigationBar setTitleTextAttributes崩溃应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文