How can I hide the Back Button Text from an UINavigation Controller? I will only have the "<" and not "< Back"
-
2you can not modify default text, instead try navigationItem.leftBarButtonItem to set custom back button – BaSha May 25 '14 at 09:06
-
http://stackoverflow.com/questions/1453519/how-to-hide-the-back-button-in-uinavigationcontroller – Ayaz May 05 '15 at 09:58
-
See my answer below, if you want a global solution using an appearance proxy. – heyfrank May 29 '20 at 13:59
36 Answers
In the interface builder, you can select the navigation item of the previous controller and change the Back Button
string to what you'd like the back button to appear as. If you want it blank, for example, just put a space.
You can also change it with this line of code:
[self.navigationItem.backBarButtonItem setTitle:@"Title here"];
Or in Swift:
self.navigationItem.backBarButtonItem?.title = ""

- 8,486
- 5
- 44
- 65
-
3Awesome tip, the one about setting an empty space on interface builder... :-D – Felipe Ferri Apr 06 '16 at 14:56
-
11Interface builder and Swift programmatic routes did not work for me in XCode 8.3.2, Swift 3 – agrippa Aug 30 '17 at 04:55
-
You can check out my very [simple solution](https://stackoverflow.com/a/46153030/3308174) for hiding all back buttons through out the app. P.S.: Requires zero line of code of your own – Pratik Jamariya Sep 20 '17 at 18:44
-
3If `Back Button` is already blank in IB, just add a space to get ride of `Back` and just show the arrow. – Tejas K Dec 08 '17 at 06:11
-
This will only set the title you specify if the `navigationItem` already has a non-nil `backBarButtonItem`. For completion's sake, you should be creating a custom button, as in the answers below, and assigning that. – royalmurder Mar 28 '18 at 13:35
-
Great tip, this is tricky since you don't see any difference when there's a space or not in Navigation Item's Back Button field. I had it working for one View Controller and couldn't find why it wasn't for another lol. – Marcos Reboucas Aug 01 '19 at 11:32
-
4This method currently works only in interface builder. Setting this from code does not work, instead of setting only the title you need to set the whole backBarButtonItem like this: navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) – Leszek Szary Dec 14 '19 at 10:17
-
You can implement UINavigationControllerDelegate
like this:
Older Swift
func navigationController(navigationController: UINavigationController, willShowViewController viewController: UIViewController, animated: Bool) {
let item = UIBarButtonItem(title: " ", style: .Plain, target: nil, action: nil)
viewController.navigationItem.backBarButtonItem = item
}
Swift 4.x
class MyNavigationController: UINavigationController, UINavigationControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
}
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
let item = UIBarButtonItem(title: " ", style: .plain, target: nil, action: nil)
viewController.navigationItem.backBarButtonItem = item
}
}
backBarButtonItem
is nil
by default and it affects next pushed controller, so you just set it for all controllers

- 450
- 7
- 16

- 1,382
- 11
- 11
-
9Thank you! This is the only solution that worked (without messing up anything else) after looking at 4 duplicate questions and dozens of answers. – inket Apr 28 '16 at 09:27
-
1I already had a navigation controller subclass that I made into it's own delegate this worked perfectly. Should update for Swift 3 though. – Dean Kelly May 19 '17 at 16:19
-
Great solution thanks, the only one that worked consistently for me. – Elliott Davies Jan 25 '18 at 02:45
-
You could also do this through storyboard. In the attribute inspector of the navigation item of the previous controller you could set " " in the Back button field. Refer Image below. Replace "Your Title here" to " ". By doing this you will achieve the desired result. You don't need to mess with the 'Title' anymore.
Programmatically you could use
[self.navigationItem.backBarButtonItem setTitle:@" "];
where self refers to the controller which pushes your desired View controller.
Sample Before, After Navigation bar
Before
After

- 1,001
- 8
- 8
-
7This works perfectly if it's set in storyboards. Just make sure that the navigation bar has a navigation item in it so that it can be set. – Jul 29 '15 at 20:08
-
12In iOS 9 / Xcode 7.3, setting the `backBarButtonItem` programmatically does not work, but setting it via the storyboard does. – Scott Gardner Mar 23 '16 at 11:31
-
@ScottGardner, setting `backBarButtonItem` programmatically [works for me](http://stackoverflow.com/a/37337255/3681880) in iOS 9. – Suragch May 20 '16 at 03:14
-
If you do not have navigation bar in your screen, maybe because it needs to be hidden, you can add navigation item in storyboard, to previous view controller and set its back button to " ". – Martin Berger Jul 02 '17 at 09:36
-
Solution worked great and very easy to implement in Xcode 9.2/iOS 11. – Ray Hunter Mar 06 '18 at 02:15
-
This method currently works only in interface builder. Setting this from code does not work, instead of setting only the title you need to set the whole backBarButtonItem like this: navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) – Leszek Szary Dec 14 '19 at 10:18
Setting title of the back button to @""
or nil
won't work. You need to set the entire button empty (without a title or image):
Objective-C
[self.navigationItem setBackBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]];
Swift
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
This should be done on the view controller that's on top of your view controller in navigation stack (i.e. from where you navigate to your VC via pushViewController
method)

- 7,501
- 5
- 28
- 50

- 1,143
- 17
- 32
-
2thank you, it works! In swift: self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, target: nil, action: nil) – mostworld77 Aug 17 '16 at 00:25
-
excellent answer.. correctly points out that merely changing the title of the default backBarButtonItem won't suffice. Bonus points for mentioning that the backBarButtonItem should be set in the previous view controller. – Crazed'n'Dazed Aug 21 '20 at 06:24
-
So this works but with iOS14's tap-and-hold back button, the little floating table view that comes up no longer shows titles of the view controllers ;( – zaitsman Jan 29 '21 at 04:17
Add the following code in viewDidLoad or loadView
self.navigationController.navigationBar.topItem.title = @"";
I tested it in iPhone and iPad with iOS 9

- 2,848
- 2
- 27
- 30
-
21
-
6
-
1If you need to do it from current view controller then to avoid removing the title from previous vc you should rather do: navigationController?.navigationBar.topItem?.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) – Leszek Szary Dec 14 '19 at 09:53
Another solution to this issue for situations where you have a great deal of view controllers is to use a UIAppearance
proxy to effectively hide the back button title text like this:
UIBarButtonItem *navBarButtonAppearance = [UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil];
[navBarButtonAppearance setTitleTextAttributes:@{
NSFontAttributeName: [UIFont systemFontOfSize:0.1],
NSForegroundColorAttributeName: [UIColor clearColor] }
forState:UIControlStateNormal];
This solution will render the text as a tiny clear dot, similar to manually setting the back button title to @" "
, except that it affects all nav bar buttons.
I don't suggest this as a general solution to the issue because it impacts all navigation bar buttons. It flips the paradigm so that you choose when to show the button titles, rather than when to hide the titles.
To choose when to show the titles, either manually restore the title text attributes as needed, or create a specialized subclass of UIBarButtonItem
that does the same (potentially with another UIAppearance
proxy).
If you have an app where most of the back button titles need to be hidden, and only a few (or none) of the nav buttons are system buttons with titles, this might be for you!
(Note: the font size change is needed even though the text color is clear in order to ensure that long titles do not cause the center nav bar title to shift over)

- 1,954
- 17
- 16
-
-
3Doesn't this also cover up an left bar button items that are not back buttons? – kevinl Dec 01 '16 at 18:22
-
1
-
2shouldn't it affect all other buttons in navigation bars including left/right bar button items? – Fyodor Volchyok Jul 19 '18 at 08:12
-
-
I tried some above and below but they didn't work. This worked for me:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.topItem?.title = ""
}

- 4,502
- 2
- 47
- 63
-
5If you need to do it from current view controller then to avoid removing the title from previous vc you should rather do: navigationController?.navigationBar.topItem?.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) – Leszek Szary Dec 14 '19 at 10:26
You can add this Objective-C category to make all "Back" buttons created by a navigation controller have no text. I just added it to my AppDelegate.m file.
@implementation UINavigationItem (Customization)
/**
Removes text from all default back buttons so only the arrow or custom image shows up.
*/
-(UIBarButtonItem *)backBarButtonItem
{
return [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
}
@end
PS - (I don't know how to make this extension work with Swift, it was having weird errors. Edits welcome to add a Swift version)

- 2,584
- 1
- 25
- 34
-
-
-
-
-
-
You should not use a category/extension to override a method. This can easily break at any time in future. – Leszek Szary Dec 14 '19 at 10:23
The only thing which works with no side-effects is to create a custom back button. As long as you don't provide a custom action, even the slide gesture works.
extension UIViewController {
func setupBackButton() {
let customBackButton = UIBarButtonItem(title: " ", style: .plain, target: nil, action: nil)
navigationItem.backBarButtonItem = customBackButton
}}
Unfortunately, if you want all back buttons in the not to have any titles, you need to setup this custom back button in all your view controllers :/
override func viewDidLoad() {
super.viewDidLoad()
setupBackButton()
}
It is very important you set a whitespace as the title and not the empty string.

- 586
- 6
- 13
The current answer wasn't working. I wanted to remove the title entirely, yet the text "back" wasn't going away.
Go back to the previous view controller and set its title property:
self.title = @" ";
ONLY works when the previous View Controller does not have a title

- 2,800
- 16
- 20
-
@ZevEisenberg make sure the property is being set prior to being displayed in the View Controller's life cycle. Meaning set it in either the viewDidLoad or viewWillAppear methods. – ChrisHaze Mar 26 '15 at 07:37
-
1
-
1It actually ended up working for me *without* spaces; just good old empty string: `@""`. – Zev Eisenberg Mar 26 '15 at 22:46
-
1@ZevEisenberg, When I first came up with the solution it was earlier in Xcode 5. With a space was the only way it worked, which is why I included it in the sample code. The Xcode 6 update must have included it. Good to know - thx – ChrisHaze Apr 09 '15 at 07:55
-
I also used my approach, which is still working, and actually removed the standard back arrow too. – ChrisHaze Apr 09 '15 at 07:58
to remove the Text from backbutton programmatically, used below Code this will work form xcode7 and above.
self.navigationController.navigationBar.topItem.title = @" ";
or
manualLy in storyboards, select the navigation bar on the view controller and put " " in back button text.
this will work. thanks

- 107
- 1
- 4
-
2
-
I edited your answer to this : `self.navigationController?.navigationBar.topItem?.title = " "` in Xcode 9 and worked ! – MHSaffari May 28 '18 at 08:20
-
If you need to do it from current view controller then to avoid removing the title from previous vc you should rather do: navigationController?.navigationBar.topItem?.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) – Leszek Szary Dec 14 '19 at 10:24
The problem with most solutions here is that setting an empty text on the back item does not work well with the new functionality for long press on back buttons. Instead of showing proper titles, it is just showing an empty list
Instead, you can use the new button display mode for iOS14 or rely on the new appearance APIs for iOS13 , to set the text to size 0. Note that some people are playing with the color (clear), that doesnt work well either because it uses the space and removes it from your titles. If the title is long enough, you will see it clipped
Resulting code:
public extension UINavigationBar {
func fixAppearance() {
if #available(iOS 14.0, *) {
topItem?.backButtonDisplayMode = .minimal
} else if #available(iOS 13.0, *) {
let newAppearance = standardAppearance.copy()
newAppearance.backButtonAppearance.normal.titleTextAttributes = [
.foregroundColor: UIColor.clear,
.font: UIFont.systemFont(ofSize: 0)
]
standardAppearance = newAppearance
} else {
topItem?.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
}
}
}
Then you just need to call that method when view controllers are presented, so either you call it from a base class (on viewWillAppear
for example) or you add some delegate to the navigation controller like in other answers of this post.

- 8,045
- 3
- 33
- 31
Alternative way - use custom NavigationBar class.
class NavigationBar: UINavigationBar {
var hideBackItem = true
private let emptyTitle = ""
override func layoutSubviews() {
if let `topItem` = topItem,
topItem.backBarButtonItem?.title != emptyTitle,
hideBackItem {
topItem.backBarButtonItem = UIBarButtonItem(title: emptyTitle, style: .plain, target: nil, action: nil)
}
super.layoutSubviews()
}
}
That is, this remove back titles whole project. Just set custom class for UINavigationController.

- 1,313
- 12
- 17
A lot of answers already, here's my two cents on the subject. I found this approach really robust. You just need to put this in viewController before segue.
Swift 4:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
}

- 2,441
- 28
- 34
Swift 5
viewController.navigationItem.backButtonDisplayMode = .minimal
Set Title of the Previous VC to " " string with space. and title with the back button will be replaced with single space string.
Self.title = " "
On Back press again reset the title to original one in the viewWillAppear.

- 2,898
- 3
- 21
- 34
Use a custom NavigationController
that overrides pushViewController
class NavigationController: UINavigationController {
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
viewController.navigationItem.backBarButtonItem =
UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
super.pushViewController(viewController, animated: animated)
}
}

- 45,645
- 31
- 257
- 263
If you're targeting iOS 13 and later you can use this new API to hide the back button title globally.
let backButtonAppearance = UIBarButtonItemAppearance()
backButtonAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.clear]
UINavigationBar.appearance().standardAppearance.backButtonAppearance = backButtonAppearance
UINavigationBar.appearance().compactAppearance.backButtonAppearance = backButtonAppearance
UINavigationBar.appearance().scrollEdgeAppearance.backButtonAppearance = backButtonAppearance
-
1This is not optimal. If a user taps the label with the clear text, the back action is still triggered. – David Apr 25 '20 at 12:27
I tried everything in this post. The only working solution is @VoidLess's
Here is the same answer but more complete
class CustomNavigationController: UINavigationController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.delegate = self
}
}
// MARK:UINavigationControllerDelegate
extension CustomNavigationController {
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
viewController.navigationItem.backBarButtonItem = UIBarButtonItem(title: " ", style: .plain, target: nil, action: nil)
}
}

- 3,763
- 21
- 37
This is my resolution for iOS11, I change the appearance of UIBarButtonItem in applicationDidFinishLaunchingWithOptions :
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(-100, 0), for:UIBarMetrics.default)
You can't change Y offset, because it will change the back bar button's position too in iOS11, but it's OK in iOS10 and below.

- 152
- 2
- 10

- 169
- 2
- 8
-
2It works but during animation you can see previous title moving on left. It looks a little bit buggy. – Jonathan Jan 04 '18 at 13:10
Swift 3.1 You can do this by implementing the delegate method of UINavigationController.
func navigationController(_ navigationController: UINavigationController,
willShow viewController: UIViewController, animated: Bool) {
/** It'll hide the Title with back button only,
** we'll still get the back arrow image and default functionality.
*/
let item = UIBarButtonItem(title: " ", style: .plain, target: nil,
action: nil)
viewController.navigationItem.backBarButtonItem = item
}

- 38,189
- 13
- 98
- 110

- 233
- 2
- 12
In Swift3,
If you set global setting
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// ..
let BarButtonItemAppearance = UIBarButtonItem.appearance()
BarButtonItemAppearance.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.clear], for: .normal)
BarButtonItemAppearance.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.clear], for: .highlighted)
// ...
}

- 453
- 6
- 18
-
1Note that this will also change the color to transparent for all other bar buttons that you might have somewhere in your app, not only back buttons. – Leszek Szary Dec 14 '19 at 10:28
For those who want to hide back button title globally.
You can swizzle viewDidLoad
of UIViewController
like this.
+ (void)overrideBackButtonTitle {
NSError *error;
// I use `Aspects` for easier swizzling.
[UIViewController aspect_hookSelector:@selector(viewDidLoad)
withOptions:AspectPositionBefore
usingBlock:^(id<AspectInfo> aspectInfo)
{
UIViewController *vc = (UIViewController *)aspectInfo.instance;
// Check whether this class is my app's view controller or not.
// We don't want to override this for Apple's view controllers,
// or view controllers from external framework.
NSString *className = NSStringFromClass([vc class]);
Class class = [NSBundle.mainBundle classNamed:className];
if (!class) {
return;
}
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStylePlain target:nil action:nil];
vc.navigationItem.backBarButtonItem = backButton;
} error:&error];
if (error) {
NSLog(@"%s error: %@", __FUNCTION__, error.localizedDescription);
}
}
Usage:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[self class] overrideBackButtonTitle];
return YES;
}

- 8,958
- 4
- 23
- 30
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.backButtonAppearance.normal.titlePositionAdjustment = UIOffset.init(horizontal: -300.0, vertical: 0.0)
}else{
let barButtonApperance = UIBarButtonItem.appearance()
barButtonApperance.setTitleTextAttributes([NSAttributedString.Key.foregroundColor:AppColor.PrimaryGray.value], for: UIControl.State.normal)
}

- 57,834
- 11
- 73
- 112

- 727
- 5
- 6
I was struggling with this because I had a custom navigation controller.
I was able to remove the back item text in all view controllers with this code in my custom navigation controller class
override func viewDidLayoutSubviews() {
self.navigationBar.backItem?.title = ""
}
This removes all of the back item titles using this custom navigation controller.

- 11
- 3
-
1Update for this: this works but there is an odd lag in loading that bothers me. I've now added this 'let BarButtonItemAppearance = UIBarButtonItem.appearance() BarButtonItemAppearance.setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.clear], for: .normal)' in the App delegate didLaunchWithOptions, and it is working perfectly! – Amy.R Mar 26 '18 at 13:48
In iOS 11, we found that setting UIBarButtonItem
appearance's text font/color to a very small value or clear color will result other bar item to disappear (system does not honor the class of UIBarButton item anymore, it will convert it to a _UIModernBarButton
). Also setting the offset of back text to offscreen will result flash during interactive pop.
So we swizzled addSubView
:
+ (void)load {
if (@available(iOS 11, *)) {
[NSClassFromString(@"_UIBackButtonContainerView") jr_swizzleMethod:@selector(addSubview:) withMethod:@selector(MyiOS11BackButtonNoTextTrick_addSubview:) error:nil];
}
}
- (void)MyiOS11BackButtonNoTextTrick_addSubview:(UIView *)view {
view.alpha = 0;
if ([view isKindOfClass:[UIButton class]]) {
UIButton *button = (id)view;
[button setTitle:@" " forState:UIControlStateNormal];
}
[self MyiOS11BackButtonNoTextTrick_addSubview:view];
}

- 625
- 4
- 15
-(void)setNavigationItems{
UIBarButtonItem *leftBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"**Your title here**" style:UIBarButtonItemStyleBordered target:self action:@selector(backButtonClicked)];
self.navigationController.navigationBar.topItem.backBarButtonItem=leftBarButtonItem;
}
-(void)backButtonClicked{
[self.navigationController popViewControllerAnimated:YES];
}

- 472
- 3
- 12
The back text come from last View Controller's navigationItem.title
,and navigationItem.title
is automaticly set by self.title
. So easy way to solve the problem is hook setTitle:
,make sure navigationItem.title = @""
Put this code at AppDelegate.m
will make it ok。
[UIViewController aspect_hookSelector:@selector(setTitle:)
withOptions:AspectPositionAfter
usingBlock:^(id<AspectInfo> aspectInfo, NSString *title) {
UIViewController *vc = aspectInfo.instance;
vc.navigationItem.titleView = ({
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
titleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
titleLabel.text = title;
titleLabel;
});
vc.navigationItem.title = @"";
} error:NULL];
More details at https://www.jianshu.com/p/071bc50f1475 (Simple Chinease)

- 374
- 1
- 4
- 10
My solution: - XCode: 10.2.1 - Swift: 5
- Parent viewcontroller:
- self.title = ""
- Child viewcontroller:
- self.navigationItem.title = "Your title" // to set title for viewcontroller

- 699
- 9
- 18
XCode 11.5 Swift 5
A very simple - though perhaps a little hacky - way of doing programmatically this if you don't need the custom back button is to set the font size equal to zero in the view controller you're pushing onto the stack, calling something like this from viewDidLoad
private func setupNavBar() {
let appearance = UINavigationBarAppearance()
appearance.configureWithDefaultBackground()
let backButtonAppearance = UIBarButtonItemAppearance()
backButtonAppearance.normal.titleTextAttributes = [.font: UIFont(name: "Arial", size: 0)!]
appearance.backButtonAppearance = backButtonAppearance
navigationItem.standardAppearance = appearance
navigationItem.scrollEdgeAppearance = appearance
navigationItem.compactAppearance = appearance
}

- 55
- 1
- 7
UINavigationControllerDelegate's navigationController(_, willShow:, animated:)
method implementation did the trick for me.
Here goes the full view controller source code. if you want to apply this throughout the app, make all viewcontrollers to derive from BaseViewController
.
class BaseViewController: UIViewController {
// Controller Actions
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.delegate = self
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
updateNavigationBar()
}
//This is for custom back button image.
func updateNavigationBar() {
let imgBack = UIImage(named: "icon_back")
self.navigationController?.navigationBar.backIndicatorImage = imgBack
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = imgBack
self.navigationItem.backBarButtonItem = UIBarButtonItem()
}
}
extension BaseViewController: UINavigationControllerDelegate {
//This is to remove the "Back" text from back button.
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
viewController.navigationItem.backBarButtonItem = UIBarButtonItem()
}
}

- 1,879
- 2
- 16
- 23
In iOS 15, I could only get the back button text to disappear using the bar appearance API. It seems like overkill, but I've ended up reusing this all over an app. Here's an extension with a bunch of other useful pieces to customize a nav bar. Setting backButtonTextColor
to .clear
does the trick for this particular issue.
extension UIViewController {
@objc func setNavBarAppearance(with backgroundColor: UIColor,
titleColor: UIColor? = nil,
shadowColor: UIColor? = nil,
tintColor: UIColor? = nil,
backButtonTextColor: UIColor? = nil) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = backgroundColor
if let titleColor = titleColor {
appearance.titleTextAttributes = [.foregroundColor: titleColor]
}
if let shadowColor = shadowColor {
appearance.shadowColor = shadowColor
}
if let tintColor = tintColor {
navigationController?.navigationBar.tintColor = tintColor
}
if let backButtonTextColor = backButtonTextColor {
let backButtonAppearance = UIBarButtonItemAppearance()
backButtonAppearance.normal.titleTextAttributes = [.foregroundColor: backButtonTextColor]
appearance.backButtonAppearance = backButtonAppearance
}
navigationController?.navigationBar.standardAppearance = appearance
navigationController?.navigationBar.scrollEdgeAppearance = appearance
}
}
Call it in your view controller's viewDidLoad
like:
setNavBarAppearance(with: .systemBackground, backButtonTextColor: .clear)

- 578
- 6
- 14
Finally found perfect solution to hide default back text in whole app.
Just add one transparent Image and add following code in your AppDelegate.
UIBarButtonItem.appearance().setBackButtonBackgroundImage(#imageLiteral(resourceName: "transparent"), for: .normal, barMetrics: .default)

- 1,882
- 2
- 27
- 44
The following method works on iOS 11 and is safe to not crash on other iOS versions. Doing this may get your app rejected in App Store review since both UIModernBarButton and UIBackButtonContainerView are private APIs. Place in AppDelegate.
if
let UIModernBarButton = NSClassFromString("_UIModernBarButton") as? UIButton.Type,
let UIBackButtonContainerView = NSClassFromString("_UIBackButtonContainerView") as? UIView.Type {
let backButton = UIModernBarButton.appearance(whenContainedInInstancesOf: [UIBackButtonContainerView.self])
backButton.setTitleColor(.clear, for: .normal)
}

- 2,035
- 17
- 27
-
Doing this may get your app rejected in App Store review since both UIModernBarButton and UIBackButtonContainerView are private APIs. – Groot Mar 14 '18 at 11:00
-
This is from my xamarin.forms code, the class derives from NavigationRenderer
NavigationBar.Items.FirstOrDefault().BackBarButtonItem = new UIBarButtonItem( "", UIBarButtonItemStyle.Plain, null);

- 10,494
- 11
- 46
- 58

- 24
- 2
Swift version, works perfectly globally:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.clearColor()], forState: UIControlState.Normal)
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.clearColor()], forState: UIControlState.Highlighted)
return true
}

- 413
- 5
- 16
-
7You should add, that this will hide **all** text also rightBarButtons and leftBarButtons, which do not go back. – limfinity Apr 27 '16 at 10:16
-
this is not a `solution`. As @limfinity pointed, it will change it universally for all the UIBarButtonItem's throughout the app – Dani Pralea Oct 07 '16 at 17:26
-
i agree with @limfinity and Danut Pralea, it'll hide all the UIBarButtonItem's text throughout the app – Pratik Jamariya May 08 '17 at 07:34