Reputation: 141
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,
Upvotes: 3
Views: 1212
Reputation: 333
*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
}
Upvotes: 0
Reputation: 333
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
}
Upvotes: 0
Reputation: 397
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];
Upvotes: 1
Reputation: 4331
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:
Then on the right panel you can find:
You just need to give some empty space in the back button box:
And you are done. Hope it will help you thanks.
Upvotes: 3
Reputation: 1214
This may help you....
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
Upvotes: 1