1

I am getting issue with iPhoneX back button image. It is not in right position as you can see in the screenshot

enter image description here

I am using below code for setting back image

class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        UINavigationBar.appearance().backIndicatorImage = #imageLiteral(resourceName: "btn-back")
        UINavigationBar.appearance().backIndicatorTransitionMaskImage = #imageLiteral(resourceName: "btn-back")
        UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -80.0), for: .default)
        return true
    }
}

Can anyone please explain why it's not at correct position and how to fix this ?

Varun Naharia
  • 5,318
  • 10
  • 50
  • 84

1 Answers1

0

You can use topItem?.title for setting up Navigation title as:

Method 1:

self.navigationController?.navigationBar.topItem?.title = ""

Output:

enter image description here

Method 2:

 let yourBackImage = UIImage(named: "back-Image")
 self.navigationController?.navigationBar.tintColor = .red//.blue as you required
 self.navigationController?.navigationBar.backIndicatorImage = yourBackImage
 self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = yourBackImage
 self.navigationController?.navigationBar.topItem?.title = ""

Output:

enter image description here

Note: As Apple Human Interface GuideLine The navigation bar back image size should be-

75px × 75px(3x)

enter image description here

Sample image 3x(75 x 75)-

enter image description here

Jack
  • 13,571
  • 6
  • 76
  • 98