0

I've removed the back button's text by manually setting it to " " on each navigation item, however there is still extra padding between the button and the navigation item's title for no reason. enter image description here

Does anyone know how to get rid of this annoying spacing? In a few real case scenarios in my app, the title does concatenate as it gets slightly too long, even though it wouldn't need to if that space were not there.

Oscar Cooke-Abbott
  • 463
  • 1
  • 6
  • 13

2 Answers2

2
override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(true)
    let arrayViews = (self.navigationController?.navigationBar.subviews)
    if let itemView = arrayViews?[1] {
        for lbl in itemView.subviews {
            lbl.frame = CGRect(x: -25, y: lbl.frame.origin.y, width: lbl.frame.size.width, height: lbl.frame.size.height)
        }
    }
}
0

You should create a custom UIBarButtonItem which uses popToViewController to go back to the previous item on your stack. That way, you can manually set the frame of your custom back button.

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223