I tried to identify what the "Back" text is from by the following:
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.setTransparent(style: .default)
print(self.navigationItem.backButtonTitle)
print(self.navigationItem.backBarButtonItem?.title)
print(self.navigationItem.title)
print(self.navigationItem.titleView?.largeContentTitle)
}
However I got all nil outputs, which means these titles are not there:
nil nil nil nil
I also tried this:
self.navigationItem.setHidesBackButton(true, animated: false)
It works but it hides the whole thing, including the back arrow "<" and the text "Back". I wanted to keep the arrow but only remove the text.
Where can I find this title or text that says "Back" and set it to empty string?
CodePudding user response:
one way is shown in attached Image.
Second one is follow:
navigationItem.backButtonTitle = ""
CodePudding user response:
This will work for you
self.navigationController?.navigationBar.topItem?.title = " "
CodePudding user response:
You can use custom left bar button item, in viewDidLoad:
let myimage = UIImage(systemName: "chevron.backward")
navigationItem.leftBarButtonItem = UIBarButtonItem(image: myimage, style: .plain, target: self, action: #selector(handleBack))
to go back the button call handleBack func:
@objc fileprivate func handleBack() {
navigationController?.popViewController(animated: true)
}