我有一个视图控制器(VCA
),它以模态方式呈现另一个视图控制器VCB
:
presentViewController(VCB, animated: true, completion: nil)
如果VCB
有modalPresentationStyle = .OverFullScreen
(同样适用于.OverCurrentContext
),为什么何时被解雇:
dismissViewControllerAnimated(true, completion: nil)
转换完成后,执行以下代码会导致VCA
变黑?
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let toVC = transitionContext.viewControllerForKey(UITransitionContextToViewContrllerKey)!
let fromVc = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
var containerView = transitionContext.containerView()!
if presenting {
toVC.view.alpha = 0
containerView.insertSubview(toVC.view, aboveSubview: fromVC.view)
} else {
containerView.insertSubview(toVC.view, belowSubview: fromVC.view)
}
UIView.animateWithDuration(transitionDuration(transitionContext), delay: 0.0, options: [.CurveEaseInOut], animations: {
if self.presenting {
self.toVC.view.alpha = 1
} else {
self.fromVC.view.alpha = 0
}
} , completion: { finished in
self.transitionContext.completeTransition(true)
})
}
在执行上述行之前,有没有办法解决这个没有删除行containerView.insertSubview(toVC.view, belowSubview: fromVC.view)
或检查fromVC.modalPresentationStyle
的值?即我可以在VCA
或VCB
的初始化程序中设置一些参数吗?
非常感谢您的帮助。