insertSubview:belowSubview仍然将视图放在swift之上3.0

问题描述:

我试图在我的应用程序中创建一个segue,以便当前视图滑动以显示它下面的视图。insertSubview:belowSubview仍然将视图放在swift之上3.0

这是我的代码:

let window = UIApplication.shared.delegate?.window! 
window?.insertSubview(destinationView, belowSubview: sourceView) 
destinationView.center = CGPoint(x: sourceView.center.x, y: sourceView.center.y) 

UIView.animate(withDuration: 0.6, animations: { 
    sourceView.center = CGPoint(x: sourceView.center.x, y: 0 - sourceView.center.y) 
}, completion: { (value: Bool) in 
    self.source.navigationController?.pushViewController(self.destination, animated: false) 
}) 

但是,我segueing的观点简单地出现在我目前的视图的顶部。关于我在做什么的任何想法都是错误的?

谢谢!

嗯,我解决了它。这里是我的情况下,任何人都有解决这个问题:

window?.insertSubview(destinationView, belowSubview: sourceView) 
window?.insertSubview(sourceView, aboveSubview: destinationView) 

我刚添加的代码,第二行和它的工作。