如何在UINavigationController中为边缘滑动禁用过渡动画?

时间:2019-07-04 11:17:37

标签: swift animation uinavigationcontroller

如何删除UINavigationController的动画?我没有为此在UINavigationController中找到属性。自定义类只是一种方法吗?

1 个答案:

答案 0 :(得分:0)

您可以在故事板上执行此操作

enter image description here

在代码中,您可以执行以下操作:

@IBAction private func nextTapped() {
    let storyBoard = UIStoryboard(name: "Main", bundle: nil)
    guard let otherViewController = storyBoard.instantiateViewController(withIdentifier: "OtherViewController") as? OtherViewController,
        let navigationController = navigationController  else {
        return
    }

    // when you push the view controller, pass in animated as false
    navigationController.pushViewController(otherViewController, animated: false)
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Next",
                                                        style: .plain,
                                                        target: self,
                                                        action: #selector(nextTapped))        
}