iOS 13 UIBarButtonItem字体

吉兹莫多

希望在导航栏的后退按钮项上有自己的自定义字体,这过去对我有用:

    let barButtonAttributes = [NSAttributedString.Key.foregroundColor : UIColor.pink,
                               NSAttributedString.Key.font : UIFont(name: "My-Awesome-Font", size: 18)!]
    UIBarButtonItem.appearance().setTitleTextAttributes(barButtonAttributes, for: .normal)
    UIBarButtonItem.appearance().setTitleTextAttributes(barButtonAttributes, for: .highlighted)

在iOS 13上,这对我来说已停止工作。有没有解决的办法?

阿什·卡梅隆(Ash Cameron)

您将要研究UINavigationBarAppearanceiOS 13中的新类。

在您的情况下:

let style = UINavigationBarAppearance()
style.buttonAppearance.normal.titleTextAttributes = [.font: #YOURFONT#]
style.doneButtonAppearance.normal.titleTextAttributes = [.font: #YOURFONT#]

navigationController?.navigationBar.standardAppearance = style
// You may want these as well:
navigationController?.navigationBar.scrollEdgeAppearance = ...
navigationController?.navigationBar.compactAppearance = ...

编辑:文档-https: //developer.apple.com/documentation/uikit/uinavigationbarappearance

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章