在iOS7中,使用UIAppearance代理时,UIBarButtonItems不尊重粗体“完成”样式

在iOS7中,默认情况下,UIBarButtonItem对样式UIBarButtonItemStylePlain使用Helvetica常规权重字体,对UIBarButtonItemStyleDone使用粗体.

我的应用程序使用自定义字体,我使用UIAppearance代理来实现此目的:

appearance = @{NSFontAttributeName: [UIFont fontWithName:@"ProximaNova-Regular" size:18.0]};
[[UIBarButtonItem appearance] setTitleTextAttributes:appearance
                                            forState:UIControlStateNormal];

麻烦的是,外观代理使Plain和Done样式按钮成为我上面指定的常规重量字体.

任何想法如何让UIBarButtonItem根据样式使用不同的自定义字体权重?

解决方法

我知道这是迟到的答案,但它对某些人有帮助:
UIBarButtonItem *customBarButton =
        [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"CustomTitle",@"This button appears in my smexy ViewController's naviagtion bar")
                                         style:UIBarButtonItemStylePlain
                                        target:self
                                        action:@selector(customButtonDidClick:)];

    NSDictionary *attributes = @{NSFontAttributeName: [UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:14.0f],NSForegroundColorAttributeName: [UIColor redColor]}; // here you can add some other keys (especially in iOS 7) to personalize your button title more 

    [customBarButton setTitleTextAttributes:attributes forState:UIControlStateNormal];

    [self.navigationItem setRightBarButtonItem:customBarButton];

编辑:感谢您检测我的拼写错误:-)

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...