viktor.radovic viktor.radovic - 6 months ago 65
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.


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)