如何更改导航控制器的根控制器在屏幕上的显示方式?

How to change the way in which the root controller of a navigation controller is appearing on screen?

导航控制器不是初始视图控制器。它在初始 VC 中实例化,并随根控制器一起提供,第二个 VC。当我调用 present view controller 函数时,我无法更改这个新 VC 的呈现方式,它总是从底部出现。我没有找到如何让它从右到左。我试图改变谁从第二个 VC 到 nav con 来回调用 modalPresentaionStyle 但没有改变。 代码清单如下。感谢您的帮助。

@objc fileprivate func showRegisterScreen() { 
    let registerAccountVC = RegisterAccountVC()
    let navigationController = UINavigationController(rootViewController: registerAccountVC)
    navigationController.modalPresentationStyle = .pageSheet
    present(navigationController, animated: true, completion: nil)
}

这将添加一个从右到左的自定义动画。

let transition = CATransition.init()
transition.duration = 0.4
transition.timingFunction = CAMediaTimingFunction.init(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight
view.window?.layer.add(transition, forKey: nil)
present(navigationController, animated: false, completion: nil)