Customize UINavigationBar Appearance Programmatically via AppDelegate

In this Swift code snippet I demonstrate how we can customize UINavigationBar appearance via the AppDelegate.swift file. The blow code covers:

  • Set UINavigationBar tint color
  • Set Navigation bar Title colour
  • Set navigation bar ItemButton tint colour
  • Set Navigation bar background image
  • Set navigation bar Back button tint colour
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

   func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        // Set navigation bar tint / background colour
        UINavigationBar.appearance().barTintColor =
        // Set Navigation bar Title colour
        UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white]
        // Set navigation bar ItemButton tint colour
        UIBarButtonItem.appearance().tintColor = UIColor.yellow
        // Set Navigation bar background image
        let navBgImage:UIImage = UIImage(named: "bg_blog_navbar_reduced.jpg")!
        UINavigationBar.appearance().setBackgroundImage(navBgImage, for: .default)
        //Set navigation bar Back button tint colour
        UINavigationBar.appearance().tintColor = UIColor.white
        return true

    func applicationWillResignActive(application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

    func applicationDidEnterBackground(application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

    func applicationWillEnterForeground(application: UIApplication) {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.

    func applicationDidBecomeActive(application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

    func applicationWillTerminate(application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.


Watch this video tutorial with demonstration on how to customize UINavigationBar Appearance.

Customize UINavigationBar appearance in Swift

Learn iOS Development with these Video Courses

How to Make a Freaking iPhone App - iOS 10 and Swift 3
icon icon

iOS 10 & Swift 3: From Beginner to Paid Professional

The Complete iOS 10 Developer Course - Build 21 Apps

Swift 3 - Learn to Code with Apple's New Language
icon icon

Learn How to Build Mobile Apps for iOS with Swift, PHP and MySQL
icon icon

Follow me on one of your favourite social networks to learn about new video tutorials and code examples:

Twitter: @SwiftVideoBlog
Google Plus:
Facebook: Swift Developer Blog on Facebook