3

I know to hide the back bar button item. But I want to hide only the title of the bar button i.e. the back button is like this: "< Back". I want only the arrow not the name i.e. "<". How do I remove the "Back" and retain only the back arrow.

Thanks,

Irfan
  • 4,301
  • 6
  • 29
  • 46
Akshara
  • 141
  • 1
  • 11
  • 2
    http://stackoverflow.com/questions/18870128/ios-7-navigation-bar-custom-back-button-without-title – iBhavin Nov 24 '15 at 03:50

5 Answers5

3

You can achieved this easily from storyboard, go to your specific view of storyboard for whom you want to show blank back button title with arrow.

Then make sure you added navigation item in your specific view:

enter image description here

Then on the right panel you can find:

enter image description here

You just need to give some empty space in the back button box:

enter image description here

And you are done. Hope it will help you thanks.

Irfan
  • 4,301
  • 6
  • 29
  • 46
1

This may help you....

self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
Ashish Ramani
  • 1,214
  • 1
  • 17
  • 30
  • For some reason this code doesn't work for me. The back bar button item still doesn't show when I use this code. – daniel Oct 20 '18 at 17:34
1

It's Easy

(1) Create LeftbarButton item

UIImage *imgBackArrow = [UIImage imageNamed:@"back_arrow"];
UIBarButtonItem *barBackButton = [[UIBarButtonItem alloc] initWithImage:imgBackArrow style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClicked)];
self.navigationItem.leftBarButtonItem = barBackButton;

(2) Hide Xcode back Button

[self.navigationItem setHidesBackButton:YES];

Maulik Patel
  • 397
  • 4
  • 15
0

You can do this by implementing the delegate method of UINavigationController.

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

0

*Swift 3.1 You can do this by implementing the delegate method of UINavigationController. It'll hide the Title with back button only, we'll still get the back arrow image and default functionality.

func navigationController(_ navigationController: UINavigationController, 
  willShow viewController: UIViewController, animated: Bool) {
        let barBttn = UIBarButtonItem(title: " ", style: .plain, target: nil, 
                    action: nil)
        viewController.navigationItem.backBarButtonItem = barBttn
    }