Wednesday, June 29, 2022
HomeTechnologyswift - Remove Navigation Bar back button text App-Wide in iOS 15...

swift – Remove Navigation Bar back button text App-Wide in iOS 15 / XCode 13


So my app has been doing the following piece of code on the didFinishLaunchingWithOptions method on the AppDelegate to hide the back button text on navigation bar:

let itemAppearance = UIBarButtonItem.appearance()
    itemAppearance.setBackButtonTitlePositionAdjustment(UIOffset(horizontal: -200, vertical: 0), for: UIBarMetrics.default)

To my surprise, among other things which I already solved (such as this), the above code no longer works on iOS 15 & XCode 13.

Ive been searching alternatives such as:

self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)

Which seem to be working just fine, however this works on a specific ViewController and Id like this to work App-Wide, having to run this code on every VC is annoying.

I tried to run the above code on the same app delegate method, but sadly I dont have access to navigationItem on AppDelegate.

Any tip is welcomed, thanks!

PD: Ideally this would need to support all the way back to iOS 13.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments