@@ -18,17 +18,30 @@ final class CollectionViewCellTransitioning: NSObject {
1818 let shrinkDuration : Double = 0.2
1919
2020 private let blurEffectView = UIVisualEffectView ( )
21- private let dimmingView = UIView ( )
2221 private let backgroundView = UIView ( )
2322
2423 override init ( ) {
2524 super. init ( )
26- blurEffectView. effect = UIBlurEffect ( style: . light)
27- dimmingView. backgroundColor = . black
25+ blurEffectView. effect = UIBlurEffect ( style: . dark)
2826 backgroundView. backgroundColor = . black
2927 }
3028}
3129
30+ // MARK: - UIViewControllerTransitioningDelegate
31+
32+ /// transition 속성을 변경하고 UIViewControllerAnimatedTransitioning를 채택한 자기 자신을 반환합니다.
33+ extension CollectionViewCellTransitioning : UIViewControllerTransitioningDelegate {
34+ func animationController( forPresented presented: UIViewController , presenting: UIViewController , source: UIViewController ) -> ( any UIViewControllerAnimatedTransitioning ) ? {
35+ transition = . present
36+ return self
37+ }
38+
39+ func animationController( forDismissed dismissed: UIViewController ) -> ( any UIViewControllerAnimatedTransitioning ) ? {
40+ transition = . dismiss
41+ return self
42+ }
43+ }
44+
3245// MARK: - UIViewControllerAnimatedTransitioning
3346extension CollectionViewCellTransitioning : UIViewControllerAnimatedTransitioning {
3447 func transitionDuration( using transitionContext: ( any UIViewControllerContextTransitioning ) ? ) -> TimeInterval {
@@ -39,7 +52,9 @@ extension CollectionViewCellTransitioning: UIViewControllerAnimatedTransitioning
3952 let containerView = transitionContext. containerView
4053 containerView. subviews. forEach { $0. removeFromSuperview ( ) }
4154
42- addBackgroundViews ( to: containerView)
55+ blurEffectView. frame = containerView. frame
56+ blurEffectView. alpha = transition. next. blurAlpha
57+ containerView. addSubview ( blurEffectView)
4358
4459 let fromView = transitionContext. viewController ( forKey: . from)
4560 let toView = transitionContext. viewController ( forKey: . to)
@@ -90,31 +105,8 @@ extension CollectionViewCellTransitioning: UIViewControllerAnimatedTransitioning
90105 }
91106}
92107
93- // MARK: - UIViewControllerTransitioningDelegate
94- extension CollectionViewCellTransitioning : UIViewControllerTransitioningDelegate {
95- func animationController( forPresented presented: UIViewController , presenting: UIViewController , source: UIViewController ) -> ( any UIViewControllerAnimatedTransitioning ) ? {
96- transition = . present
97- return self
98- }
99-
100- func animationController( forDismissed dismissed: UIViewController ) -> ( any UIViewControllerAnimatedTransitioning ) ? {
101- transition = . dismiss
102- return self
103- }
104- }
105-
106108// MARK: - Methods
107109extension CollectionViewCellTransitioning {
108- private func addBackgroundViews( to containerView: UIView ) {
109- blurEffectView. frame = containerView. frame
110- blurEffectView. alpha = transition. next. blurAlpha
111- containerView. addSubview ( blurEffectView)
112-
113- dimmingView. frame = containerView. frame
114- dimmingView. alpha = transition. next. dimmingAlpha
115- containerView. addSubview ( dimmingView)
116- }
117-
118110 private func copy( of thumbnailView: ThumbnailView ) -> ThumbnailView {
119111 let thumbnailViewCopy = ThumbnailView ( with: thumbnailView. size)
120112 thumbnailViewCopy. configure ( with: thumbnailView. imageView. image)
@@ -124,7 +116,6 @@ extension CollectionViewCellTransitioning {
124116 private func makeShrinkAnimator( of thumbnailView: ThumbnailView ) -> UIViewPropertyAnimator {
125117 UIViewPropertyAnimator ( duration: shrinkDuration, curve: . linear) {
126118 thumbnailView. transform = CGAffineTransform ( scaleX: 0.95 , y: 0.95 )
127- self . dimmingView. alpha = 0.8
128119 }
129120 }
130121
@@ -146,7 +137,6 @@ extension CollectionViewCellTransitioning {
146137 }
147138
148139 self . blurEffectView. alpha = self . transition. blurAlpha
149- self . dimmingView. alpha = self . transition. dimmingAlpha
150140
151141 self . backgroundView. layer. cornerRadius = self . transition. next. cornerRadius
152142 self . backgroundView. frame = containerView. frame
0 commit comments