Reputation: 503
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.
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.
Upvotes: 0
Views: 1353
Reputation: 160
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)
}
}
}
Upvotes: 2
Reputation: 58029
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.
Upvotes: 0