Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove "<" from UINavigationItem Back Button

How can I remove the "<" from the UINavigationItem Back Button. I have a UIViewController on my storyboard that's opened with a Push segue. I'd like to just have the text on the back button, and not the back arrow.

So far, I added this code to the prepareForSegue function in the calling UITableViewController.

        let backItem = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle., target: nil, action: nil)
        navigationItem.backBarButtonItem = backItem

When the UIView comes up, it has "< Done" in the text of the back button. How can I set it up so that it just has "Done"?

like image 711
Scott Kilbourn Avatar asked Jul 08 '15 03:07

Scott Kilbourn


People also ask

How do I get rid of the back button in SwiftUI?

The . navigationBarBackButtonHidden(true) will hide the back button.

How do I hide the Navigation bar back button in swift 5?

Way 1: Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.


2 Answers

Add this 2 line of code in your appdelegate. It will remove back indicator from all the view controllers.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    UINavigationBar.appearance().backIndicatorImage = UIImage()
    UINavigationBar.appearance().backIndicatorTransitionMaskImage = UIImage()

}

If you are getting space in left side then set title position

UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(-20, 0), for: UIBarMetrics.default)
like image 68
Ashish Kakkad Avatar answered Oct 24 '22 16:10

Ashish Kakkad


In viewDidLoad

self.navigationItem.setHidesBackButton(true, animated: false)

If you have a custom UINavigationBar set leftBarButtonItem to nil

like image 33
Black Sheep Avatar answered Oct 24 '22 17:10

Black Sheep