0

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?

enter image description here

RainCast
  • 4,134
  • 7
  • 33
  • 47
  • Does this answer your question? [Remove text from Back button keeping the icon](https://stackoverflow.com/questions/33025239/remove-text-from-back-button-keeping-the-icon) – Ankur Lahiry Jun 09 '22 at 06:35

3 Answers3

2

This will work for you

self.navigationController?.navigationBar.topItem?.title = " "
Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50
0

one way is shown in attached Image.

Second one is follow:

navigationItem.backButtonTitle = ""

enter image description here

Sham Kumar
  • 204
  • 1
  • 5
  • print(navigationItem.backButtonTitle) is actually nil, and setting it to nil or empty string doesn't do anything. – RainCast Jun 09 '22 at 06:04
  • Please use this method, may be it solve your problem, func setBackItem() { let backItem = UIBarButtonItem() backItem.title = AppConstants.empty navigationItem.backBarButtonItem = backItem navigationItem.backButtonTitle = AppConstants.empty } – Sham Kumar Jun 09 '22 at 06:42
0

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)
}
Fabio
  • 5,432
  • 4
  • 22
  • 24