From bf9ec1751344c0552d5683bd303515ece6553c24 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 5 Feb 2025 11:33:32 -0500 Subject: [PATCH] Fix gallery crossfade transition not working when gallery presented from modally-presented VC --- .../GalleryVC/GalleryDismissAnimationController.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift index 7eeb0cc6..3925ddbf 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift @@ -168,10 +168,17 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans return } + let container = transitionContext.containerView + + // See comment above. + if toVC.view.superview == nil { + toVC.view.frame = container.bounds + container.addSubview(toVC.view) + } + toVC.view.frame = transitionContext.containerView.bounds fromVC.view.frame = transitionContext.containerView.bounds - transitionContext.containerView.addSubview(toVC.view) - transitionContext.containerView.addSubview(fromVC.view) + container.addSubview(fromVC.view) let duration = transitionDuration(using: transitionContext) let animator = UIViewPropertyAnimator(duration: duration, curve: .easeInOut)