Alejandro Cumpa
Alejandro Cumpa

Reputation: 2363

Place backItem on top of UINavigation Bar

I am new to iOS development, and I need to achieve some design I've got, it's a big navigation bar with the back item on top (Android like), I have customize the navigation but I can't make the back button appears on top of it. How to do that?

What I want.

enter image description here

What I have

enter image description here

I am using Xcode 7 with Swift 2.

Upvotes: 0

Views: 40

Answers (1)

Josh Gafni
Josh Gafni

Reputation: 2881

If you are using a UINavigationController, you automatically get a back button when you push a UIViewController onto the navigation stack. Note that you don't get one on the UINavigationController's root view controller, because there is nothing to go back to.

The back button you get automatically may say < Back, or it may base the title on the title of the UIViewController you would go back to. So if my root view controller is titled Menuand I have pushed a view controller that is titledDetails, then the back button might say< Menu`.

If you want a Back button either on the root view controller or a Back button that says something else, then unfortunately, you can't use the Back button that you get for free. You need to disable the default back button, and add a left bar button item to the navigation bar. You must also implement the "going back" that happens when you tap the button, i.e. the popping of the view controller / unwind segue.

Upvotes: 1

Related Questions