Remove text from Back button keeping the icon

前端 未结 29 2706
栀梦
栀梦 2020-11-28 23:26

I want to remove the text from the back button, but I want to keep the icon. I have tried

let backButton = UIBarButtonItem(title: \"\", style: UIBarButtonIt         


        
29条回答
  •  情书的邮戳
    2020-11-29 00:19

    The easiest way to do this programmatically is to set backBarButtonItem from the parent view controller (a controller that calls push).

    class ViewController: UIViewController {
        override func viewDidLoad() {
            super.viewDidLoad()
    
            let backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
            navigationItem.backBarButtonItem = backBarButtonItem
        }
    }
    

    More detail here https://sarunw.com/posts/how-to-remove-text-from-uinavigationbar-back-button/

提交回复
热议问题