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)
I'm using this line of code in AppDelegate
file into didFinishLaunchingWithOptions
method to remove the backbutton title
.
Swift 2.x
let barAppearace = UIBarButtonItem.appearance()
barAppearace.setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), forBarMetrics:UIBarMetrics.Default)
Swift 3.x
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), for:UIBarMetrics.default)
Swift 4.x
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.clear], for: .normal)
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.clear], for: UIControlState.highlighted)
Just need go to your Parent ViewController from where your other ViewControllers are dependent.
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(true)
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, target: nil, action: nil)}
Work's like charm on Swift 3
self.navigationController?.navigationBar.topItem?.title = " "