title: Transitioning Animation, UIViewControllerAnimatedTransitioning dismiss error?
body: <p><code>Xcode 12.5.1</code> with <code>Swift version 5.4.2</code></p>
  <p>I use the following code to do Transitioning Animation for viewController dismissing</p>
  <pre><code>enum PresentingDirection{
      case top, right, left, bottom
      
      var bounds: CGRect{
          UIScreen.main.bounds
      }
      
      func offsetF(withFrame viewFrame: CGRect) -&gt; CGRect{
          let h = bounds.size.height
          let w = bounds.size.width
          switch self {
          case .top:
              return viewFrame.offsetBy(dx: 0, dy: -h)
          case .bottom:
              return viewFrame.offsetBy(dx: 0, dy: h)
          case .left:
              return viewFrame.offsetBy(dx: -w, dy: 0)
              
          case .right:
              return viewFrame.offsetBy(dx: w, dy: 0)
              
          }
          
      }
  }
  
  
  class CustomDismissController: NSObject, UIViewControllerAnimatedTransitioning{
      
      
      fileprivate var presentingDirection: PresentingDirection
      
      
      init(direction orientation: PresentingDirection) {
          presentingDirection = orientation
      }
      
      
      func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -&gt; TimeInterval {
          return 1
      }
      
      
      func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
          
          guard let fromCtrl = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from),
                let toCtrl = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to), let toView = toCtrl.view else{
              return
          }
          
          let finalCtrlFrame = transitionContext.finalFrame(for: fromCtrl)
          let containerView = transitionContext.containerView
          fromCtrl.view.alpha = 0.5
          toView.frame = presentingDirection.offsetF(withFrame: finalCtrlFrame)
      
  
          containerView.bringSubviewToFront(toView)
    
          UIView.animate(withDuration: transitionDuration(using: transitionContext), delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.0, options: .curveLinear) {
              toView.frame = finalCtrlFrame
         
          } completion: { _ in
              let success = !transitionContext.transitionWasCancelled
              transitionContext.completeTransition(success)
          }
      }
  }
  
  </code></pre>
  <p>The above is the the best I can do.</p>
  <p>I want the effect <code>fromCtrl.view.alpha = 1</code></p>
  <p>As I tested, <code>fromCtrl.view.alpha = 0.5</code>  is very important.</p>
  <p>Without it, the second view controller stays , I can not see the first view controller's frame animation</p>
  <p><strong>It seems like to be an iOS bug</strong></p>
  <p>Any good idea?</p>
  <p>I also tried <code>snapshotView</code></p>
  <pre><code>func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
          
          guard let fromCtrl = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from),
                let toCtrl = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to), let toView = toCtrl.view, let snapshot = fromCtrl.view.snapshotView(afterScreenUpdates: false) else{
              return
          }
          
          let finalCtrlFrame = transitionContext.finalFrame(for: fromCtrl)
          let containerView = transitionContext.containerView
          fromCtrl.view.isHidden = true
          snapshot.frame = finalCtrlFrame
          containerView.addSubview(snapshot)
          toView.frame = presentingDirection.offsetF(withFrame: finalCtrlFrame)
      
  
          containerView.bringSubviewToFront(toView)
    
          UIView.animate(withDuration: transitionDuration(using: transitionContext), delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.0, options: .curveLinear) {
              toView.frame = finalCtrlFrame
         
          } completion: { _ in
              let success = !transitionContext.transitionWasCancelled
              transitionContext.completeTransition(success)
          }
  
      }
  
  </code></pre>
  <p>Not good.</p>
  <p><a href="https://github.com/coyingcat/TransitionsLearn/tree/main/one" rel="nofollow noreferrer">full code in github</a></p>