Swift – How to hide back button in navigation item?

5 Solutions Collect From Internet About “Swift – How to hide back button in navigation item?”

Straight from the UINavigationItem class reference documentation –

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

In my case it only worked this way :

override func viewWillAppear(animated: Bool) {
    self.tabBarController?.navigationItem.hidesBackButton = true

You may try with the below code

override func viewDidAppear(_ animated: Bool) {
    self.navigationController?.isNavigationBarHidden = true

You can try this code

self.navigationController?.setNavigationBarHidden(true, animated: false)

Hide or show the navigation bar. If animated, it will transition
vertically using UINavigationControllerHideShowBarDuration

open func setNavigationBarHidden(_ hidden: Bool, animated: Bool) 

This is also found in the UINavigationController class documentation:

navigationItem.hidesBackButton = true