Swift Custom NavBar Back Button Image and Text
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Customizing the iOS navigation bar back button is possible, but the cleanest solution depends on how much you want to change. If you only want a custom chevron image or different text, UIKit already provides better hooks than fully replacing the back button. If you replace the back button entirely with leftBarButtonItem, you gain full control but you also take over the pop behavior yourself.
So the first question is whether you need a true custom control or just a custom appearance. In many cases, changing the back indicator image and the previous controller's back title is the safer choice.
Prefer System Back Behavior When Possible
If you want custom text on the back button, configure it on the previous view controller, not the current one:
If you want a custom back arrow image for the whole navigation bar, set backIndicatorImage on the navigation bar appearance:
This preserves the default swipe-back gesture and system back-button behavior.
Fully Custom Back Button with Image and Text
If you truly need a custom image plus custom text inside one button, hide the default back button and provide a left bar button item:
This gives you complete control over spacing, font, image choice, and title content.
The Trade-Off: Swipe-Back Gesture
A fully custom left bar button item is not identical to the system back button. One subtle difference is that interactive pop behavior can be affected depending on navigation-controller setup.
If preserving the edge-swipe back gesture matters, test it after customization. In some setups you may need to ensure the navigation controller's interactive pop gesture recognizer remains enabled.
That is why appearance-level customization is often better than replacing the control outright.
A Good Hybrid Approach
A practical middle ground is:
- use the system back behavior
- customize the back indicator image globally
- set the back title on the previous view controller
That gives you image and text customization while keeping the default navigation semantics. Fully custom buttons should be reserved for cases where the system back button really cannot achieve the design requirement.
Common Pitfalls
- Setting the back-button title on the wrong view controller. The back title is usually configured on the previous controller in the stack.
- Replacing the back button with
leftBarButtonItemwhen only the arrow image needed customization. - Forgetting to call
popViewControllermanually after hiding the default back button. - Breaking or changing the interactive swipe-back experience without noticing.
Summary
- If possible, customize appearance instead of replacing the back button entirely.
- Set custom back text on the previous view controller with
backButtonTitle. - Use navigation bar appearance to change the back indicator image.
- Use a custom
leftBarButtonItemonly when you truly need full control of image and text. - After full replacement, test pop behavior and swipe-back interaction carefully.
Related reading
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.