diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift index 72a3fa96..29dd5143 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift @@ -59,9 +59,17 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated let content = itemViewController.takeContent() content.view.translatesAutoresizingMaskIntoConstraints = true - container.addSubview(to.view) - container.addSubview(content.view) + // Use a separate dimming view from to.view, so that the gallery controls can be in front of the moving content. + let dimmingView = UIView() + dimmingView.backgroundColor = .black + dimmingView.frame = container.bounds + dimmingView.layer.opacity = 0 + container.addSubview(dimmingView) + container.addSubview(content.view) + container.addSubview(to.view) + + to.view.backgroundColor = nil to.view.layer.opacity = 0 content.view.frame = sourceFrameInContainer content.view.layer.opacity = 0 @@ -77,6 +85,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated let animator = UIViewPropertyAnimator(duration: duration, timingParameters: spring) animator.addAnimations { + dimmingView.layer.opacity = 1 + to.view.layer.opacity = 1 content.view.frame = destFrameInContainer @@ -90,6 +100,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated } animator.addCompletion { _ in + to.view.backgroundColor = .black + if sourceToDestTransform != nil { self.sourceView.transform = origSourceTransform }