Removing the title text of an iOS UIBarButtonItem

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.

Leave a Comment