• Home
  • About
  • Our Apps
  • Learn
  • Contact
Login

Register

Login
Seemu Apps Seemu Apps
  • Home
  • About
  • Our Apps
  • Learn
  • Contact

Tutorial – Set Navigation Bar Color

Home ios Tutorial – Set Navigation Bar Color

Tutorial – Set Navigation Bar Color

Mar 3, 2016 | Posted by Andrew | ios, swift, tutorial, xcode |

You can simply set the Navigation Bar Color in XCode using one line of code.

I have setup a XCode project with a simple navigation controller as the root view controller of the default view. It looks like:

navigationcontroller

To set the navigation bar color simply add the following line of code in viewDidLoad()

    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.navigationBar.barTintColor = UIColor.redColor()
    }

If you run the app you will now see the Navigation Bar has a red color to it:

navbarred

To set it to a custom color use the RGB code as follows, replacing the 100 with your relevant RGB codes.

    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.navigationBar.barTintColor = UIColor(red: 100/255, green: 100/255, blue: 100/255, alpha: 1)
    }

The above line of code sets it to gray using the RGB colors as follows:

navbarrgb

DownloadSourceCode

Tags: colornavigationnavigation baruinavigationuinavigationbar
0
Share

About Andrew

Andrew is a 24 year old from Sydney. He loves developing iOS apps and has done so for two years.

You also might be interested in

Tutorial – Transparent UI Navigation Bar

Feb 21, 2016

Making the UINavigation bar transparent & see through is easy[...]

Tutorial – Set UINavigation Bar Title Image

Mar 23, 2016

Making the UINavigation bar have a title image of your[...]

Tutorial – Custom Navigation Bar Back Arrow

Mar 23, 2016

You can simply set the Navigation Bar back image style with[...]

Welcome

Hi I am Andrew and welcome to Seemu Apps! Have a look around, we provide tutorials for primarily iOS apps.
Bluehost website hosting discount

Seemu’s Studio Setup

Blue Yeti Microphone
Rode Stand
Spider Shock Mount
Mac Keyboard Cover
Screenflow - recording software

Contact Us

We're currently offline. Send us an email and we'll get back to you, asap.

Send Message

Footer

:)

© 2025 · Your Website. Theme by HB-Themes.

  • Home
  • About
  • Our Apps
  • Learn
  • Contact
Prev Next