iOS 7 UIBarButtonItem设置字体突出显示时不起作用

时间:2013-10-11 04:00:25

标签: ios7 uibarbuttonitem

[[UIBarButtonItem appearance] setTitleTextAttributes:titleAttributes forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes:titleAttributes forState:UIControlStateSelected];
[[UIBarButtonItem appearance] setTitleTextAttributes:titleAttributes forState:UIControlStateDisabled];

我使用这些功能更改导航栏项目的字体和颜色,它在iOS 7之前工作正常,但在iOS 7中,当在此视图控制器中显示警报时,左侧导航项将其颜色更改为蓝色且字体更大。搜索后,我可以使用

 [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; 

将颜色更改为蓝色。

但是如何更改字体?

1 个答案:

答案 0 :(得分:0)

将此添加到'titleAttributes'字典:

NSDictionary *titleAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:16.0], UITextAttributeFont,  nil];