How to customize the navigation back symbol and navigation back text?

You can hide back button text in many ways.Try this simple approach.

Step1: Goto your mainstoryBoard and click navigationBar.

Step 2: Goto Attributes Inspector under Navigation Item add a BLANK SPACE in Back Button

enter image description here

Step 3: If you want to change backButton text method is pretty much the same.

enter image description here

Update 1: If you want to use an image as a back button check this link


Update 2:

Method 2: Using custom image as a back button.

Paste below code into your detailVC and set image for your back Button.

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

   title = "Detail VC"

    let customButton = UIBarButtonItem(image: UIImage(named: "back"), style: .plain, target: self, action: #selector(backButtonTapped)) //
    self.navigationItem.leftBarButtonItem  = customButton  
}

func backButtonTapped() {     
   _ = navigationController?.popToRootViewController(animated: true)  
}

I am setting back button image in assets catalogue with the 32pixel size.I am not sure about the asset image size.Check with apple doc about the size class.

enter image description here

Output:

enter image description here

Leave a Comment