When I push a UIViewController
, it has some title in back button at new UIViewController
, if the title has a lot of text, It does not look good in
You could create a subclass for all UIViewController
s you want this behavior for, and in the subclass's viewDidLoad
:
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.backBarButtonItem = UIBarButtonItem(
title: "", style: .plain, target: nil, action: nil)
}
This way, you can choose which controllers you want the behavior for, without duplicating code. I prefer my controllers to just say "Back", rather than the title of the previous controller, so I set that title here.