UINavigationBar Hide back Button Text UINavigationBar Hide back Button Text ios ios

UINavigationBar Hide back Button Text


In the interface builder, you can select the navigation item of the previous controller and change the Back Button string to what you'd like the back button to appear as. If you want it blank, for example, just put a space.

You can also change it with this line of code:

[self.navigationItem.backBarButtonItem setTitle:@"Title here"];

Or in Swift:

self.navigationItem.backBarButtonItem?.title = ""


You can implement UINavigationControllerDelegate like this:

Older Swift

func navigationController(navigationController: UINavigationController, willShowViewController viewController: UIViewController, animated: Bool) {    let item = UIBarButtonItem(title: " ", style: .Plain, target: nil, action: nil)    viewController.navigationItem.backBarButtonItem = item}

Swift 4.x

class MyNavigationController: UINavigationController, UINavigationControllerDelegate {    override func viewDidLoad() {        super.viewDidLoad()        self.delegate = self    }    func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {        let item = UIBarButtonItem(title: " ", style: .plain, target: nil, action: nil)        viewController.navigationItem.backBarButtonItem = item    }}

backBarButtonItem is nil by default and it affects next pushed controller, so you just set it for all controllers


You could also do this through storyboard. In the attribute inspector of the navigation item of the previous controller you could set " " in the Back button field. Refer Image below. Replace "Your Title here" to " ". By doing this you will achieve the desired result. You don't need to mess with the 'Title' anymore.

Programmatically you could use

[self.navigationItem.backBarButtonItem setTitle:@" "];

where self refers to the controller which pushes your desired View controller.

Xcode view controller navigation item

Sample Before, After Navigation bar

BeforeBefore

AfterAfter