How to Change back button title on navigation controller in swift3?

后端 未结 8 567
天命终不由人
天命终不由人 2020-12-06 18:54

I want to change the title of backbutton to any name in swift 3.I tried many ways but none of them worked for me.

self.navigationItem.backBarButtonItem?.titl         


        
8条回答
  •  离开以前
    2020-12-06 19:23

    This is the way:

    extension UINavigationController {
        func addCustomBackButton(title: String = "Back") {
            let backButton = UIBarButtonItem()
            backButton.title = title
            navigationBar.topItem?.backBarButtonItem = backButton
        }
    }
    

提交回复
热议问题