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

Register

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

UINavigation Bar background image

Home ios UINavigation Bar background image

UINavigation Bar background image

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

Making the UINavigation bar have a background image of your choice is easy with two lines 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

First of all we have added the following gummi_bear_navbar to our assets.xcassets for the background image we will be using in this tutorial.

gummi_bear_navbar

Screen Shot 2016-02-18 at 7.06.10 pm

Now to change the navigation bar image simply use the following code:

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        let navBackgroundImage = UIImage(named: "gummi_bear_navbar") // Get our image
        self.navigationController!.navigationBar.setBackgroundImage(navBackgroundImage, for: .default) // Set the Nav Bar Image
}

Now your navigation bar will have a background image as follows:

Screen Shot 2016-02-18 at 7.14.08 pm

DownloadSourceCode

 

Tags: backgroundbarbar backgroundnavigationnavigation backgrounduinavigationuinavigationbar
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 – Pass data between View Controllers using a Segue

Aug 2, 2015

In the last tutorial we looked at navigating view controllers[...]

Tutorial – Navigation between View Controllers

Jul 30, 2015

In this tutorial we will look at navigation in Swift,[...]

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