'hide back button title on navigation bar not working for iOS 13 and above

I have added the following code to hide the back button title on the navigation bar but it is not working on iOS 15.

UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffset(horizontal: -1000, vertical: 0),
                                                                      for: UIBarMetrics.default)

can someone help me plz?



Solution 1:[1]

You will want to do this on your navigation bar button:

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

The title will need to be an empty string and that gets rid of the title.

Solution 2:[2]

I have resolve this by using following method :

let appearance = UINavigationBarAppearance()    
appearance.backButtonAppearance.normal.titlePositionAdjustment = UIOffset(horizontal: -1000, vertical: 0)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ralph Lee
Solution 2 Speedy