Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c ios7 UINavigationBar setTitleTextAttributes应用程序崩溃_Objective C_Ios7 - Fatal编程技术网

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]
初始化字体