Godfather
Godfather

Reputation: 4330

iOS custom back button bad transition

I want to customize the image for a back button in just a viewController. So for this viewController i have:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationController?.navigationBar.backIndicatorImage = #customImage
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    navigationController?.navigationBar.backIndicatorImage = #restoreImage
}

But when im displaying the previous viewController (viewWillDissapear is called) this previous viewController wait until its displayed to set the image (if i swippe this doesnt happen):

enter image description here

Upvotes: 0

Views: 101

Answers (1)

McDonal_11
McDonal_11

Reputation: 4075

Here, changes of image (imageSize 40 * 40) working fine. You can try this.

SecondViewController:

override func viewWillAppear(_ animated: Bool) {
    var backButtonImage = UIImage(named: "lineBack.png")
    UIBarButtonItem.appearance().setBackButtonBackgroundImage(backButtonImage, for: .normal, barMetrics: .default)
}

ThirdViewController:

override func viewWillAppear(_ animated: Bool) {
    var backButtonImage = UIImage(named: "roundBack.png")
    UIBarButtonItem.appearance().setBackButtonBackgroundImage(backButtonImage, for: .normal, barMetrics: .default)
}

Upvotes: 1

Related Questions