Ios 使用BackburbuttonItem禁用动画
正如我的标题所说,有没有办法自定义默认的后退按钮操作方法 我试图在谷歌上找到答案,但没有得到任何符合我要求的答案Ios 使用BackburbuttonItem禁用动画,ios,swift,uinavigationcontroller,uinavigationitem,Ios,Swift,Uinavigationcontroller,Uinavigationitem,正如我的标题所说,有没有办法自定义默认的后退按钮操作方法 我试图在谷歌上找到答案,但没有得到任何符合我要求的答案 我知道将uiBarButtonim添加到self.navigationItem.LeftBarButtonim和自定义操作方法的一种方法,但我将隐藏一个选项是在视图控制器上实现ViewWillEnglish方法并设置animationEnable No override func viewWillDisappear(animated : Bool) { super.viewWillD
我知道将
uiBarButtonim
添加到self.navigationItem.LeftBarButtonim
和自定义操作方法的一种方法,但我将隐藏一个选项是在视图控制器上实现ViewWillEnglish方法并设置animationEnable No
override func viewWillDisappear(animated : Bool) {
super.viewWillDisappear(animated)
UIView.setAnimationsEnabled(false)
}
override func viewDidDisappear(_ animated: Bool) {
UIView.setAnimationsEnabled(false)
}
您必须在那里添加自定义栏按钮
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(frame: YourDesiredFrame)
button.setImage(UIImage(named : "back"), for: .normal)
button.addTarget(self, action: #selector(backButtonTapped(_:)), for: .touchUpInside)
let barButton = UIBarButtonItem(customView: button)
self.navigationItem.backBarButtonItem = barButton
}
func backButtonTapped(_ sender : UIButton) {
_ = self.navigationController?.popViewController(animated : false)
}
不会有帮助,因为我只想禁用移动动画,并且在移动开始时ViewWillEnglishe方法调用,但它将禁用应用程序所有屏幕的动画,因此我们需要为所有相关屏幕管理True您的预期输出是什么?适当地阐述你的问题。
// Swift 4
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
// turn on animations
UIView.setAnimationsEnabled(true)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// turn off animations
UIView.setAnimationsEnabled(false)
}