Change font of back navigation bar button

前端 未结 7 1131
走了就别回头了
走了就别回头了 2020-12-04 17:38

I want to be able to set the font of my apps navigation bar back button without doing anything too crazy and without losing any other design characteristics of the button (i

7条回答
  •  鱼传尺愫
    2020-12-04 18:08

    In Swift3:

    let font = UIFont(name: "Verdana", size: 10.0)
    
    // Back button
    UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: font!], for: UIControlState.normal)  
    
    // Title in the navigation item
    let fontAttributes = [NSFontAttributeName: font]
    self.navigationController?.navigationBar.titleTextAttributes = fontAttributes
    

    Note: you only have to do this once for the Navigation controller.

提交回复
热议问题