我试图更改导航 Controller 后退按钮的字体大小,但无济于事。
我目前在以前的 View Controller 中执行此操作 viewWillAppear
:
navigationController?.navigationBar.backItem?.backBarButtonItem?.setTitleTextAttributes(
[NSAttributedStringKey.font : UIFont.systemFont(ofSize: 5)], for: .normal)
上面的代码什么也没做.. 那么,两个问题。
首先,更改后退按钮字体大小的正确方法是什么(顺便说一下,这似乎比应该的要困难得多)。
其次,是否有一个单一的地方(如 AppDelegate)我可以进行此更改以影响所有 View Controller ?
最佳答案
您可以在 AppDelegate 中更改它:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.font: UIFont(name: "SF Pro Display", size: 17)!], for: .normal)
return true
}
您可以在其中自定义导航栏按钮的字体和大小,以便它在所有 View Controller 中发生变化。
关于ios - 如何更改导航 Controller 后退按钮的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48733365/