Titletextattributes Uiappearance Font in iOS 7

How to change the font and text color of the title of UINavigationBar

It seems this is needed as well:

self.navigationController?.navigationBar.barStyle       = UIBarStyle.Black // I then set the color using:

self.navigationController?.navigationBar.barTintColor = UIColor(red: 204/255, green: 47/255, blue: 40/255, alpha: 1.0) // a lovely red

self.navigationController?.navigationBar.tintColor = UIColor.whiteColor() // for titles, buttons, etc.

let navigationTitleFont = UIFont(name: "Avenir", size: 20)!

self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: navigationTitleFont]

Change font of UINavigationController title

The title view can be any view. So just create a UILabel or something else where you change the font and assign that new view to the title property of the navigation item.

Setting UIBarButtonItem appearance resulted in weird behaviour with back button

I managed to fix the issue for solution 1, but honestly have no idea why I need both normal and highlighted state for it to work properly.

Need to add the following

UIBarButtonItem.appearance(whenContainedInInstancesOf: [UINavigationBar.self]).setTitleTextAttributes(attributes, for: .highlighted)


Related Topics



Leave a reply



Submit