From 206d1e5057323c85658ae879f8821cd18b70657f Mon Sep 17 00:00:00 2001 From: Eric Jensen Date: Wed, 29 May 2024 10:19:29 -0400 Subject: [PATCH 1/3] Configure cross dissolve image transition view to better mimic the original image view --- Sources/NukeExtensions/ImageViewExtensions.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/NukeExtensions/ImageViewExtensions.swift b/Sources/NukeExtensions/ImageViewExtensions.swift index 4d1665cde..be5e303c1 100644 --- a/Sources/NukeExtensions/ImageViewExtensions.swift +++ b/Sources/NukeExtensions/ImageViewExtensions.swift @@ -410,12 +410,17 @@ extension ImageViewController { // Create a transition view which mimics current view's contents. transitionView.image = imageView.image transitionView.contentMode = imageView.contentMode - imageView.superview?.insertSubview(transitionView, aboveSubview: imageView) transitionView.frame = imageView.frame + transitionView.tintColor = imageView.tintColor + transitionView.tintAdjustmentMode = imageView.tintAdjustmentMode + transitionView.preferredImageDynamicRange = imageView.preferredImageDynamicRange + transitionView.preferredSymbolConfiguration = imageView.preferredSymbolConfiguration + transitionView.isHidden = imageView.isHidden transitionView.clipsToBounds = imageView.clipsToBounds transitionView.layer.cornerRadius = imageView.layer.cornerRadius transitionView.layer.cornerCurve = imageView.layer.cornerCurve transitionView.layer.maskedCorners = imageView.layer.maskedCorners + imageView.superview?.insertSubview(transitionView, aboveSubview: imageView) // "Manual" cross-fade. transitionView.alpha = 1 From 4131f39b83e765098266e8c021de633c150cb141 Mon Sep 17 00:00:00 2001 From: Eric Jensen Date: Wed, 29 May 2024 10:18:28 -0400 Subject: [PATCH 2/3] Prevent retaining the cross dissolve transition view longer than needed --- Sources/NukeExtensions/ImageViewExtensions.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/NukeExtensions/ImageViewExtensions.swift b/Sources/NukeExtensions/ImageViewExtensions.swift index be5e303c1..2df8e5c3d 100644 --- a/Sources/NukeExtensions/ImageViewExtensions.swift +++ b/Sources/NukeExtensions/ImageViewExtensions.swift @@ -435,9 +435,10 @@ extension ImageViewController { transitionView.alpha = 0 imageView.alpha = 1 }, - completion: { isCompleted in - if isCompleted { + completion: { [weak transitionView] isCompleted in + if isCompleted, let transitionView { transitionView.removeFromSuperview() + transitionView.image = nil } } ) From 2638b29cdb1d9e55a5792d16a5b6d6295e64dfe3 Mon Sep 17 00:00:00 2001 From: Eric Jensen Date: Wed, 29 May 2024 10:58:02 -0400 Subject: [PATCH 3/3] Fix compilation when using Xcode < 15.0 --- Sources/NukeExtensions/ImageViewExtensions.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/NukeExtensions/ImageViewExtensions.swift b/Sources/NukeExtensions/ImageViewExtensions.swift index 2df8e5c3d..e76797d5d 100644 --- a/Sources/NukeExtensions/ImageViewExtensions.swift +++ b/Sources/NukeExtensions/ImageViewExtensions.swift @@ -413,7 +413,9 @@ extension ImageViewController { transitionView.frame = imageView.frame transitionView.tintColor = imageView.tintColor transitionView.tintAdjustmentMode = imageView.tintAdjustmentMode + #if swift(>=5.9) // preferredImageDynamicRange was back-ported to all iOS/tvOS versions, but only available when using the iOS/tvOS 17+ SDKs transitionView.preferredImageDynamicRange = imageView.preferredImageDynamicRange + #endif transitionView.preferredSymbolConfiguration = imageView.preferredSymbolConfiguration transitionView.isHidden = imageView.isHidden transitionView.clipsToBounds = imageView.clipsToBounds