我想在viewController中自定义后退按钮的图像。 所以对于这个viewController我有:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.navigationBar.backIndicatorImage = #customImage
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.navigationBar.backIndicatorImage = #restoreImage
}
但是当我显示前一个viewController(调用viewWillDissapear)时,这个前一个viewController会等到它显示为设置图像(如果我swippe这不会发生):
答案 0 :(得分:1)
这里,图像的变化(imageSize 40 * 40)工作正常。你可以试试这个。
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)
}