【发布时间】:2019-12-24 11:38:12
【问题描述】:
我尝试制作过渡动画以在两个 viewController 之间进行切换。有什么方法可以在不使用情节提要的情况下做到这一点?
这段代码用于调用新的viewController(我没有使用storyboard):
@objc func handleAccount() {
let navController = UINavigationController(rootViewController: userButtonLauncher())
navController.transitioningDelegate = self
navController.modalPresentationStyle = .custom
self.present(navController, animated: true, completion: nil)
}
这个转换代码:
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
transition.transitionMode = .present
transition.startingPoint = CGPoint(x: 0, y: 0)
return transition
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
transition.transitionMode = .pop
transition.startingPoint = CGPoint(x: 0, y: 0)
return transition
}
【问题讨论】:
-
尝试搜索
push viewController programmatically -
嗨,Lu,我已经尝试过推送 viewController,但我认为转换页面覆盖了 viewController。当我写 'let navController = UINavigationController(rootViewController: userButtonLauncher()) navController.transitioningDelegate = self navController.modalPresentationStyle = .custom self.present(navController, animated: true, completion: nil)' 时。转换页面下的 UserButtonLauncher。我只看到空白页。
标签: ios swift iphone xcode swift3