最佳答案
创建一个对象并提供自定义呈现
动画:
class TheVendor: NSObject, UIViewControllerTransitioningDelegate {
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return TheAnimator()
}
}
然后创建动画师:
class TheAnimator: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
// return a duration
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
// return the custom animation
}
}
然后,当您呈现
时,进行正确的绑定(bind):
presentedViewController.transitioningDelegate = TheVendor()
presentedViewController.modalPresentationStyle = .custom
关于swift - 如何创建模态动画,其中向上滑动屏幕上半部分,向下滑动屏幕下半部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49777489/