viktor.radovic viktor.radovic - 1 year ago 109
Swift Question

Swift move back button to Toolbar?

In my project, I want to add back button in toolbar at the bottom of display.

I have my UIViewController embedded inside Navigation Controller, and also I have bottom toolbar. But back button is by default in top left part of navigation controller.

Answer Source

You cant move back button from navBat to toolbar, but you can add custom button.

self.tabBarController?.navigationItem.hidesBackButton = true
self.navigationController?.toolbarHidden = false
var items = [UIBarButtonItem]()
    IBarButtonItem( title: "Back", style: .Plain, target: self, action: #selector(gotoBack))
self.navigationController?.toolbar.items = items

and add to ViewController function

func gotoBack(){
    self.navigationController?.popViewController(animated: true)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download