Swift: Customizing Colors of Navigation and Tab Bars
I'm in the final stages of a rather large iOS project, and I've been tweaking the UI so that it reflects the app's branding. One simple change that I've made is to modify the colors of the app's navigation bar.
Here's some Swift code that changes the navigation bar's background color to blue, and the color of the nav bar items to white. (Note that in this example, the view is being managed by a navigation controller.)
// Change the navigation bar background color to blue.
navigationController!.navigationBar.barTintColor = UIColor.blueColor()
// Change the color of the navigation bar button items to white.
navigationController!.navigationBar.tintColor = UIColor.whiteColor()
Here's what the navigation bar looks like.
The title is still being displayed in the default (black) color. To change its color, you would use something like this:
// Change the color of the navigation bar title text to yellow.
And here's what that additional change looks like.
I was experimenting with all of this, and found that you can easily change the title's font as well. For example, here's code that changes the title's font to BradleyHandITCTT-Bold, its size to 36 points, and the color to yellow.