---
title: "Appearance bites - Little Bites of Cocoa"
description: "Little Bites of Cocoa about Appearance: short tips and techniques for iOS and Mac development, each a brief explanation of one concept, technique or tool."
url: "https://littlebitesofcocoa.com/topics/45-appearance"
author: "Jake Marsh"
---
# Bites about: [Appearance](https://littlebitesofcocoa.com/topics/45-appearance)

Topics

- [UIKit](https://littlebitesofcocoa.com/topics/1-uikit)
- [Appearance](https://littlebitesofcocoa.com/topics/45-appearance)

## [#72: Customizing Navigation Bars 🍀](https://littlebitesofcocoa.com/72-customizing-navigation-bars)

 Tuesday September 1st, 2015

Topics

- [UIKit](https://littlebitesofcocoa.com/topics/1-uikit)
- [Appearance](https://littlebitesofcocoa.com/topics/45-appearance)

**Navigation Bars** are a versatile part of iOS. Let's take a look at some different ways we can customize their appearance and behavior.

## Custom Fonts and Colors

```swift
let nba = UINavigationBar.appearance()
let bba = UIBarButtonItem.appearance()

let titleTextAttributes = [ NSFontAttributeName : navBarFont ]

nba.barTintColor = green
nba.tintColor = darkGreen
nba.titleTextAttributes = titleTextAttributes

bba.setTitleTextAttributes(titleTextAttributes, forState: .Normal)
```

![Image 1 of 3 from bite #72: Customizing Navigation Bars](https://media.littlebitesofcocoa.com/bite-assets/072-customizing-navigation-bars-1.png)

## Hide/Show Navigation Bar when Scrolling

```swift
navigationController?.hidesBarsOnSwipe = true
```

This will cause our **navigation bar** to slide on and off screen as the user scrolls, just like in Safari for iOS.

## Empty Back Button

We want a **back button** with no text. We *could* set the **title** of our first **view controller** to an empty string, but then our first **view controller** would be title-less. We can get the best of both worlds by giving the first **view controller** a custom **back button item** with an empty title. We'll need to do this *before* we push on a new **view controller**.

```swift
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, target: nil, action: nil)
```

![Image 2 of 3 from bite #72: Customizing Navigation Bars](https://media.littlebitesofcocoa.com/bite-assets/072-customizing-navigation-bars-2.png)

## Use an Image as a Title

```swift
let imageView = UIImageView(image: UIImage(named: "app-logo")!)
navigationItem.titleView = imageView
```

![Image 3 of 3 from bite #72: Customizing Navigation Bars](https://media.littlebitesofcocoa.com/bite-assets/072-customizing-navigation-bars-3.png)

 

 
