     let fromViewController = transitionContext.viewController(forKey: .from)
     let toViewController = transitionContext.viewController(forKey: .to)
     
-    fromViewController?.beginAppearanceTransition(false, animated: true)
-    toViewController?.beginAppearanceTransition(true, animated: true)
-    
     if transitionMode == .present {
+      fromViewController?.beginAppearanceTransition(false, animated: true)
+      if toViewController?.modalPresentationStyle == .custom {
+        toViewController?.beginAppearanceTransition(true, animated: true)
+      }
+      
       let presentedControllerView = transitionContext.view(forKey: UITransitionContextViewKey.to)!
       let originalCenter = presentedControllerView.center
       let originalSize = presentedControllerView.frame.size

        transitionContext.completeTransition(true)
        self.bubble.isHidden = true
        fromViewController?.endAppearanceTransition()
        toViewController?.endAppearanceTransition()
      })
    } else {
      let key = (transitionMode == .pop) ? UITransitionContextViewKey.to : UITransitionContextViewKey.from
      let returningControllerView = transitionContext.view(forKey: key)!
      let originalCenter = returningControllerView.center

        self.bubble.removeFromSuperview()
        transitionContext.completeTransition(true)
        
        if fromViewController?.modalPresentationStyle == .custom {
          fromViewController?.endAppearanceTransition()
        }
        toViewController?.endAppearanceTransition()
      })
    }
