我正在尝试进行自定义设置,该设置与Xcode
中默认设置的设置相反(这是从下到上)。我的意思是,我希望当前的VC消失,而我一直认为要支持它的VC。问题是,在我当前的代码中,VC过渡到顶部,因此我的segue不显示动画,因为它隐藏在该VC后面。如何拥有它,以使当前的VC处于最佳状态?
我的代码:
override func perform() {
animateDown()
}
func animateDown() {
var firstVCView = self.source.view
var secondVCView = self.destination.view
// Get the screen width and height.
let screenWidth = UIScreen.main.bounds.size.width
let screenHeight = UIScreen.main.bounds.size.height
// Specify the initial position of the destination view.
secondVCView!.frame = CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight)
// Access the app's key window and insert the destination view above the current (source) one.
let window = UIApplication.shared.keyWindow
window?.insertSubview(secondVCView!, aboveSubview: firstVCView!)
// Animate the transition.
UIView.animate(withDuration: 2, animations: { () -> Void in
secondVCView!.frame = firstVCView!.frame.offsetBy(/*secondVCView!.frame, */dx: 0.0, dy: screenHeight)
}) { (Finished) -> Void in
self.source.present(self.destination as! UIViewController,
animated: false,
completion: nil)
}
}