1

I have an app that uses custom segue animations (based on https://www.appcoda.com/custom-segue-animations/). It has worked for years, but since iOS 13, the unwind segues aren't animating (black screen then just appears, instead of sliding in).

When I set the view controllers to have the new modalPresentationStyle to .fullScreen. The animation doesn't work, but it does with the default one.

Here's my code:

class TransitionManagerHorizonal: UIStoryboardSegue {

  override func perform() {
    // Assign the source and destination views to local variables.
    var unwind = false

    let firstVCView = source.view as UIView?
    let secondVCView = destination.view as UIView?

    let id = horizontalUnwindSegues.filter {$0 == identifier}
    if id.count > 0 {
        unwind = true
    }

    // Get the screen width and height.
    let screenWidth = UIScreen.main.bounds.size.width
    let offScreenRight = CGAffineTransform(translationX: screenWidth, y: 0)
    let offScreenLeft = CGAffineTransform(translationX: -screenWidth, y: 0)

    // Specify the initial position of the destination view.
    secondVCView?.transform = offScreenLeft

    // 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?.transform = offScreenRight
        secondVCView?.transform = CGAffineTransform.identity

        }, completion: { (Finished) -> Void in

            if unwind {
                self.destination.dismiss(animated: false, completion: nil)     
            } else {
                self.source.present(self.destination ,
                    animated: false,
                    completion: nil)
            }
    }) 

  }

}

Curiously, I have another transition manager that just uses alpha for the animation, and that one works well. Moving the view when it's full screen seems to be the issue.

coopersita
  • 5,011
  • 3
  • 27
  • 48

0 Answers0