Ios CATTransition在过渡期间变黑

Ios CATTransition在过渡期间变黑,ios,swift,catransition,Ios,Swift,Catransition,我正在两个视图控制器上执行一个简单的从右到左的转换。动画效果完美,正是我想要的结果。但是,由于演示/演示视图控制器淡入/淡出,我在背景中看到一个黑色闪光灯 我的过渡: let transition = CATransition() transition.duration = 2.25 // Slow duration to see the black. transition.type = kCATransitionPush transition.subtype = kCATransitionFr

我正在两个视图控制器上执行一个简单的从右到左的转换。动画效果完美,正是我想要的结果。但是,由于演示/演示视图控制器淡入/淡出,我在背景中看到一个黑色闪光灯

我的过渡:

let transition = CATransition()
transition.duration = 2.25 // Slow duration to see the black.
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight
view.window!.layer.add(transition, forKey: kCATransition)
present(vc, animated: false, completion: nil)
我读到在AppDelegate didFinishLaunchingWithOptions中设置窗口颜色可以解决这个问题,但是,这似乎没有起到任何作用。(黑色在过渡期间仍然可见。)


关于让两个VC在过渡期间不出现黑色闪烁有什么建议吗?谢谢。

我以前在执行自定义转换时遇到过完全相同的问题,就像您在上面的
prepare(for:sender:)
中所做的那样。我读完后设法解决了这个问题

在故事板内部,选择您的segue,选择自定义种类并应用自定义的
SegueFromBottom
类:

以下是Swift 3的更新代码

import UIKit

class SegueFromBottom: UIStoryboardSegue
{
    override func perform()
    {
        // Assign the source and destination views to local variables.
        let firstVCView = self.source.view as UIView!
        let secondVCView = self.destination.view as UIView!

        // 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.0, y: screenHeight, 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: 0.4, animations: { () -> Void in
            firstVCView?.frame = (firstVCView?.frame.offsetBy(dx: 0.0, dy: -screenHeight))!
            secondVCView?.frame = (secondVCView?.frame.offsetBy(dx: 0.0, dy: -screenHeight))!
        }, completion: { (Finished) -> Void in
            self.source.present(self.destination as UIViewController, animated: false, completion: nil)
        })
    }
}
import UIKit

class SegueFromBottom: UIStoryboardSegue
{
    override func perform()
    {
        // Assign the source and destination views to local variables.
        let firstVCView = self.source.view as UIView!
        let secondVCView = self.destination.view as UIView!

        // 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.0, y: screenHeight, 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: 0.4, animations: { () -> Void in
            firstVCView?.frame = (firstVCView?.frame.offsetBy(dx: 0.0, dy: -screenHeight))!
            secondVCView?.frame = (secondVCView?.frame.offsetBy(dx: 0.0, dy: -screenHeight))!
        }, completion: { (Finished) -> Void in
            self.source.present(self.destination as UIViewController, animated: false, completion: nil)
        })
    }
}