Change the navigation bar's font

前端 未结 7 1420
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 10:41

The question is plain easy and simple, the answer unfortunately not.

How can you change the font of the text in the UINavigationBar?

7条回答
  •  遥遥无期
    2020-12-02 10:58

    Not sure why all the answers included the shadow. Adding the lines that manipulate the shadow does nothing in respect to changing text font. These 2 lines of code will work for iOS 8.4 and Swift

    let attributesDictionary = [NSFontAttributeName: UIFont(name: "Helvetica Neue", size: 14)!]
    navigationController!.navigationBar.titleTextAttributes = attributesDictionary
    

    The titleTextAttributes stores a dictionary that will dictate the font, color, size, and other attributes of the navigation bar's title.

提交回复
热议问题