Swift change font and color of back button
Swift 3.0 answer (based on Lion's answer):
let newFont = UIFont(name: "Avenir Next", size: 16.0)!
let color = UIColor.white
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UINavigationBar.classForCoder() as! UIAppearanceContainer.Type]).setTitleTextAttributes([NSForegroundColorAttributeName: color, NSFontAttributeName: newFont], for: .normal)
Works a treat, for those that have already managed to customise other parts of their nav bars but not the back button!
If you want to set same color to bar buttons implicitly then in your AppDelegate
, in didfinishlaunchingwithoptions
, write:
UINavigationBar.appearance().tintColor = UIColor.white //your desired color here
Update :
Put this in AppDelegate
,
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont(name: "Andes Rounded", size: 17)!], forState: .Normal) // your textattributes here
Update 2 :
UIBarButtonItem.appearanceWhenContainedInInstancesOfClasses([UINavigationBar.classForCoder()]).setTitleTextAttributes(["attribute" : "value"], forState: .Normal)
Hope this will help :)