Removing the title text of an iOS UIBarButtonItem
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-60, -60)
forBarMetrics:UIBarMetricsDefault];
Then you can remove the back button item title.
If you use Storyboard, you can set navigation attributes inspector Back Button with space.
If you are using Storyboards you can go to Attributes Inspector
of the ViewController's Navigation Item
(click on Navigation Bar
) and set the Back Button
property to " " (one space character). This will set the Back Button title to one space character, leaving the chevron visible. No need to mess with code.
Note that this will set Back Button
title for the Back Button that will segue to this View Controller from the one that was pushed on top of it, not for the Back Button
that will be displayed inside this Controller!
To set the back button title for a view controller without changing its title use:
Objective-C:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:self.navigationItem.backBarButtonItem.style target:nil action:nil];
Swift:
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
To be clear, this is done on the view controller that you would see if you hit the back button. i.e. instead of seeing '< Settings' you want to just see '<' then on your SettingsViewController you would put this in your init
. Then you don't get any of the problems of the title not showing when you're looking at the view controller itself.