I want to incorporate a custom back button - I'm able to get the above result using
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back-btn"] style:UIBarButtonItemStylePlain target:nil action:nil];
but how do you remove the native blue button?
In iOS7+ you can use navigationBar's
backIndicatorImage
andbackIndicatorTransitionMaskImage
to achieve the custom arrow that you want. Swift code below:If you want to hide the "back" text you can set the
title
of the previous view to be an single space " " or use a customUIBarButtonItem
that doesn't have a title.I just faced the exact same problem, here's what I ended up doing:
Here's the image-scaling method:
Credit for the scaling method above goes to Paul Lynch on this SO question: (The simplest way to resize an UIImage?)