     // MARK: - Private
     fileprivate func animatePresentation(_ transitionContext: UIViewControllerContextTransitioning)
     {
-        guard let sourceViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
-            else { return }
-        
-        guard let targetViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)
-            else { return }
-        
-        guard let sourceViewSnapshot = sourceViewController.view.snapshotView(afterScreenUpdates: false)
-            else { return }
+        guard let sourceViewController = transitionContext.viewController(forKey: .from)
+            else { return }
+        
+        guard let targetViewController = transitionContext.viewController(forKey: .to)
+            else { return }
+        
+        guard let sourceViewSnapshotImage = sourceViewController.view.screenshot()
+            else { return }
+        
+        let sourceViewSnapshot = UIImageView(image: sourceViewSnapshotImage)
         
         let containerView = transitionContext.containerView
         

    
    fileprivate func animateDismissal(_ transitionContext: UIViewControllerContextTransitioning)
    {
        guard let sourceViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
            else { return }
        
        guard let targetViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)
            else { return }
        
        guard let targetViewSnapshot = targetViewController.view.snapshotView(afterScreenUpdates: false)
            else { return }
        
        let containerView = transitionContext.containerView
        

        return CGRect(x: 0, y: relativeView.frame.height, width: relativeView.frame.width, height: relativeView.frame.height)
    }
}

extension UIView {
    func screenshot() -> UIImage? {
        UIGraphicsBeginImageContextWithOptions(bounds.size, false, 0);
        drawHierarchy(in: bounds, afterScreenUpdates: false)
        let screenshot = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        
        return screenshot
    }
}
