How can I change the font of the back button for my navigation bar?

后端 未结 6 1363
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 03:02

How can I change the font of the back button for my navigation bar.

The back button is either \"back\" or the title from the previous view controller.

I tho

6条回答
  •  春和景丽
    2020-11-29 03:36

    For iOS 13, Swift 5.1:

    let fontAttr = [NSAttributedString.Key.font: \*your font*\]
    
    let buttonAppearance = UIBarButtonItemAppearance()
    buttonAppearance.normal.titleTextAttributes = fontAttr
    
    let navbarAppearance = UINavigationBarAppearance()
    navbarAppearance.buttonAppearance = buttonAppearance
    UINavigationBar.appearance().standardAppearance = navbarAppearance
    

提交回复
热议问题