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
Updated Answer For Swift 4.2
Working with UIAppearance
is a cleaner way of solving the problem but it would cause all the UIBarButtonItem
to have a clear text. An improved version of the solution could be to check if the UIBarButtonItem
is contained in a UINavigationBar
.
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UINavigationBar.self]).setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.clear], for: .normal)