iOS7 UIBarButtonItem后退按钮使用动态类型

时间:2014-07-29 22:14:21

标签: objective-c ios7

我将导航栏标题的字体设置为使用动态类型 即

self.navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName:[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]};

哪个有效,但后退按钮不采用此字体。 我试过了

[self.navigationItem.backBarButtonItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]} forState:UIControlStateNormal];

但这还没有奏效。

enter image description here

1 个答案:

答案 0 :(得分:2)

看起来唯一的方法是创建一个新的UIBarButtonItem:

UIBarButtonItem *dynamicTypeButton = [[UIBarButtonItem alloc] init];
[dynamicTypeButton setTitleTextAttributes:@{NSFontAttributeName:[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]} forState:UIControlStateNormal];
self.navigationItem.backBarButtonItem = dynamicTypeButton;