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

Register

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

Tutorial – Custom Navigation Bar Back Arrow

Home ios Tutorial – Custom Navigation Bar Back Arrow

Tutorial – Custom Navigation Bar Back Arrow

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

You can simply set the Navigation Bar back image style with a small amount of code. The arrow color will still be the same as the navigation bar tint color (Tbe default is blue) – but the style will be changed.

I have setup a XCode project with a simple navigation controller as the root view controller of the default view. With an extra view added, with a segue to open it. It looks like:

Screen Shot 2016-03-03 at 5.47.58 pm

We are going to change the back button arrow from this:

Screen Shot 2016-03-03 at 8.47.36 pm

to look like:

Screen Shot 2016-03-03 at 8.47.52 pm

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

dback

Screen Shot 2016-03-03 at 8.51.50 pm

 

Then simply add the following code to the viewDidLoad(), see the comments on each line for a brief explanation of what it does!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Used to center the image, you may need to adjust the top and bottom to move your image up or down if it is not centered.
        let inserts = UIEdgeInsets(top: 0,left: 0,bottom: -5,right: 0)
        let imgBackArrow = UIImage(named: "dback")?.withAlignmentRectInsets(inserts) // Load the image centered
        
        self.navigationController?.navigationBar.backIndicatorImage = imgBackArrow // Set the image
        self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = imgBackArrow // Set the image mask
     }

And volia, your back button will be set to the image style you used as a mask!

Screen Shot 2016-03-03 at 8.47.52 pm

DownloadSourceCode

Tags: backbarnavigation baruinavigation
3
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 – Set UINavigation Bar Title Image

Mar 23, 2016

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

Tutorial – Transparent UI Navigation Bar

Feb 21, 2016

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

Tutorial – Set Navigation Bar Color

Mar 3, 2016

You can simply set the Navigation Bar Color in XCode[...]

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