Pan Ziyue Pan Ziyue - 5 months ago 25x
iOS Question

Removing the title text of an iOS UIBarButtonItem

What I wanted to do is to remove the text from the 'Back' button of a

, leaving only the blue chevron on the navigation bar. Keep in mind that I'm developing for iOS 7. I've tried several methods, including, but not limited to:

This is the image method which I did not like (the image looked out of place):

UIBarButtonItem *barBtnItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"iOS7BackButton"] style:UIBarButtonItemStylePlain target:self action:@selector(goToPrevious:)];
self.navigationItem.leftBarButtonItem = barBtnItem;

Another method I tried was this, which simply did not work (nothing was displayed):

UIBarButtonItem *barBtn = [[UIBarButtonItem alloc]init];

What I wanted to achieve is something like the back buttons found in the iOS 7 Music app, which only featured a single chevron.


[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)

Then you can remove the back button item title.

If you use Storyboard, you can set navigation attributes inspector Back Button with space.