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

后端 未结 8 581
天命终不由人
天命终不由人 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:22

    You will have to set the backBarButtonItem property of the navigationItem of the viewController that you push the said viewController from.

    self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.plain, target: nil, action: nil)
    

    However, you must set this for each viewController.

提交回复
热议问题