Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mayooresan/9a4f4aac95af9917078864bfbb383456 to your computer and use it in GitHub Desktop.
Save mayooresan/9a4f4aac95af9917078864bfbb383456 to your computer and use it in GitHub Desktop.
This is a sample that can be reused to change the font / colours / tint of your navigation bar.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// Override point for customization after application launch.
UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
let navigationController : UINavigationController = self.window?.rootViewController as! UINavigationController
// Change the navigation bar background color to blue.
navigationController.navigationBar.barTintColor = UIColor(red: 243/255, green: 129/255, blue: 37/255, alpha: 0)
// Change the color of the navigation bar button items to white.
navigationController.navigationBar.tintColor = UIColor.white
let font : UIFont = UIFont (name: "Avenir Next Medium", size: 14)! // Unwrapped
let colour = UIColor.white
let attributes: [String : AnyObject] = [NSFontAttributeName: font, NSForegroundColorAttributeName: colour]
navigationController.navigationBar.titleTextAttributes = attributes
let font2 : UIFont = UIFont (name: "Avenir Next Medium", size: 16)! // Unwrapped
let colour2 = UIColor.white
let attributes2: [String : AnyObject] = [NSFontAttributeName: font2, NSForegroundColorAttributeName: colour2]
UIBarButtonItem.appearance().setTitleTextAttributes(attributes2, for: UIControlState())
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment