UINavigationBar Hide back Button Text
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 = ""
Remove text from Back button keeping the icon
I know this already has an answer, but you can also do it in code (in case you're working with nibs)
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
Add the above in the first view controller.
Note that you need to do this for each view controller that is pushing. So if you have 3 view controllers, and you want to remove the back text from all of them, you'll have to add the line in view controller 1 and 2.
Change UINavigationBar back button title
Do this in the parent view controller not in the child
Swift
navigationItem.backBarButtonItem = UIBarButtonItem(title: "Back", style: .plain, target: nil, action: nil)
Objetive-C
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
Remove UINavigationBar back button title
Just set the title
of the back button to ""
Here's a example in swift
self.navigationItem.backBarButtonItem = UIBarButtonItem(
title: "",
style: UIBarButtonItemStyle.Plain,
target: nil,
action: nil)
To do it in all the view controllers, i usually make a BaseViewController
where i include that line in the viewDidLoad
method. Then when i have a viewcontroller i subclass it to the BaseViewController
.
Your solution could work if you also move the x value -150, but for me it sounds like hack because you are still showing it all the time, but off the view bounds.
How to remove all navigationbar back button title
If you want back arrow so following code put into AppDelegate
file into didFinishLaunchingWithOptions
method.
For Objective-C
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
For Swift
let BarButtonItemAppearance = UIBarButtonItem.appearance()
BarButtonItemAppearance.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.clear], for: .normal)
Another option give below.
In Objective C
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
In Swift
self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.plain, target:nil, action:nil)
UPDATE :
let BarButtonItemAppearance = UIBarButtonItem.appearance()
let attributes: [NSAttributedStringKey: Any] = [
BarButtonItemAppearance.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.clear], for: .normal)
NSAttributedStringKey.font: UIFont.systemFont(ofSize: 0.1),
NSAttributedStringKey.foregroundColor: UIColor.clear]
BarButtonItemAppearance.setTitleTextAttributes(attributes, for: .normal)
BarButtonItemAppearance.setTitleTextAttributes(attributes, for: .highlighted)
UPDATE SWIFT 4.1 :
let attributes = [NSAttributedStringKey.font: UIFont(name: "Helvetica-Bold", size: 0.1)!, NSAttributedStringKey.foregroundColor: UIColor.clear]
BarButtonItemAppearance.setTitleTextAttributes(attributes, for: .normal)
BarButtonItemAppearance.setTitleTextAttributes(attributes, for: .highlighted)
Using Offset
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(-1000, 0), for:UIBarMetrics.default)
How to hide back button title on iOS7 with NavigationController
Finally ended up solving it as follows , this one worked perfect.
self.navigationController.navigationBar.topItem.title = @"";
from this link Removing the title text of an iOS UIBarButtonItem
But if you navigate from previous view to next view you can see that the title of the previous view navigation bar vanishes when i put the above mentioned solution in viewDidDisappear of viewWillDisappear of previous view, which isn't an elegant solution in storyboard based UINavigationController scenario , in another situation i finally decided to use a bar button and set its image as per the native back button chevron, this gives better results.
Related Topics
How to Mimic the Bottom Sheet from the Maps App
Sorting Array Alphabetically With Number
Uibutton Action in Table View Cell
Get a List of All Contacts on Ios
Check For Internet Connection Availability in Swift
Uicollectionview Inside a Uitableviewcell - Dynamic Height
How to Handle Background Audio Playing While iOS Device Is Locked or on Another Application
iOS 7 Tableview Like in Settings App on iPad
Changing Specific Text's Color Using Nsmutableattributedstring in Swift
Uitextfield's Numerical Pad: Dot Instead of Comma for Float Values
Xcode 7 Error: "Missing iOS Distribution Signing Identity For ..."
Firebase Notification Records/Log API
How to Run App in Simulator: Xcode Beta 6 iOS 8
Storyboard Doesn't Contain a View Controller With Identifier
How to Determine If an Annotation Is Inside of Mkpolygonview (Ios)
How to Programmatically Connect to a Wifi Network Given the Ssid and Password