@@ -54,13 +54,15 @@ final internal class BounceUpTransition: TransitionAnimator {
5454 switch direction {
5555 case . in:
5656 to. view. bounds. origin = CGPoint ( x: 0 , y: - from. view. bounds. size. height)
57- UIView . animate ( withDuration: 0.6 , delay: 0.0 , usingSpringWithDamping: 0.6 , initialSpringVelocity: 0 , options: [ . curveEaseOut] , animations: {
57+ UIView . animate ( withDuration: 0.6 , delay: 0.0 , usingSpringWithDamping: 0.6 , initialSpringVelocity: 0 , options: [ . curveEaseOut] , animations: { [ weak self] in
58+ guard let self = self else { return }
5859 self . to. view. bounds = self . from. view. bounds
59- } , completion: { completed in
60- transitionContext. completeTransition ( completed )
60+ } , completion: { _ in
61+ transitionContext. completeTransition ( true )
6162 } )
6263 case . out:
63- UIView . animate ( withDuration: outDuration, delay: 0.0 , options: [ . curveEaseIn] , animations: {
64+ UIView . animate ( withDuration: outDuration, delay: 0.0 , options: [ . curveEaseIn] , animations: { [ weak self] in
65+ guard let self = self else { return }
6466 self . from. view. bounds. origin = CGPoint ( x: 0 , y: - self . from. view. bounds. size. height)
6567 self . from. view. alpha = 0.0
6668 } , completion: { _ in
@@ -84,13 +86,15 @@ final internal class BounceDownTransition: TransitionAnimator {
8486 switch direction {
8587 case . in:
8688 to. view. bounds. origin = CGPoint ( x: 0 , y: from. view. bounds. size. height)
87- UIView . animate ( withDuration: 0.6 , delay: 0.0 , usingSpringWithDamping: 0.6 , initialSpringVelocity: 0 , options: [ . curveEaseOut] , animations: {
89+ UIView . animate ( withDuration: 0.6 , delay: 0.0 , usingSpringWithDamping: 0.6 , initialSpringVelocity: 0 , options: [ . curveEaseOut] , animations: { [ weak self] in
90+ guard let self = self else { return }
8891 self . to. view. bounds = self . from. view. bounds
89- } , completion: { completed in
90- transitionContext. completeTransition ( completed )
92+ } , completion: { _ in
93+ transitionContext. completeTransition ( true )
9194 } )
9295 case . out:
93- UIView . animate ( withDuration: outDuration, delay: 0.0 , options: [ . curveEaseIn] , animations: {
96+ UIView . animate ( withDuration: outDuration, delay: 0.0 , options: [ . curveEaseIn] , animations: { [ weak self] in
97+ guard let self = self else { return }
9498 self . from. view. bounds. origin = CGPoint ( x: 0 , y: self . from. view. bounds. size. height)
9599 self . from. view. alpha = 0.0
96100 } , completion: { _ in
@@ -113,13 +117,15 @@ final internal class ZoomTransition: TransitionAnimator {
113117 switch direction {
114118 case . in:
115119 to. view. transform = CGAffineTransform ( scaleX: 0.1 , y: 0.1 )
116- UIView . animate ( withDuration: 0.6 , delay: 0.0 , usingSpringWithDamping: 0.6 , initialSpringVelocity: 0 , options: [ . curveEaseOut] , animations: {
120+ UIView . animate ( withDuration: 0.6 , delay: 0.0 , usingSpringWithDamping: 0.6 , initialSpringVelocity: 0 , options: [ . curveEaseOut] , animations: { [ weak self] in
121+ guard let self = self else { return }
117122 self . to. view. transform = CGAffineTransform ( scaleX: 1 , y: 1 )
118- } , completion: { completed in
119- transitionContext. completeTransition ( completed )
123+ } , completion: { _ in
124+ transitionContext. completeTransition ( true )
120125 } )
121126 case . out:
122- UIView . animate ( withDuration: outDuration, delay: 0.0 , options: [ . curveEaseIn] , animations: {
127+ UIView . animate ( withDuration: outDuration, delay: 0.0 , options: [ . curveEaseIn] , animations: { [ weak self] in
128+ guard let self = self else { return }
123129 self . from. view. transform = CGAffineTransform ( scaleX: 0.1 , y: 0.1 )
124130 self . from. view. alpha = 0.0
125131 } , completion: { _ in
@@ -143,13 +149,15 @@ final internal class FadeTransition: TransitionAnimator {
143149 case . in:
144150 to. view. alpha = 0
145151 UIView . animate ( withDuration: 0.6 , delay: 0.0 , options: [ . curveEaseOut] ,
146- animations: {
152+ animations: { [ weak self] in
153+ guard let self = self else { return }
147154 self . to. view. alpha = 1
148- } , completion: { completed in
149- transitionContext. completeTransition ( completed )
155+ } , completion: { _ in
156+ transitionContext. completeTransition ( true )
150157 } )
151158 case . out:
152- UIView . animate ( withDuration: outDuration, delay: 0.0 , options: [ . curveEaseIn] , animations: {
159+ UIView . animate ( withDuration: outDuration, delay: 0.0 , options: [ . curveEaseIn] , animations: { [ weak self] in
160+ guard let self = self else { return }
153161 self . from. view. alpha = 0.0
154162 } , completion: { _ in
155163 transitionContext. completeTransition ( !transitionContext. transitionWasCancelled)
@@ -167,7 +175,8 @@ final internal class DismissInteractiveTransition: TransitionAnimator {
167175
168176 override func animateTransition( using transitionContext: UIViewControllerContextTransitioning ) {
169177 super. animateTransition ( using: transitionContext)
170- UIView . animate ( withDuration: outDuration, delay: 0.0 , options: [ . beginFromCurrentState] , animations: {
178+ UIView . animate ( withDuration: outDuration, delay: 0.0 , options: [ . beginFromCurrentState] , animations: { [ weak self] in
179+ guard let self = self else { return }
171180 self . from. view. bounds. origin = CGPoint ( x: 0 , y: - self . from. view. bounds. size. height)
172181 self . from. view. alpha = 0.0
173182 } , completion: { _ in
0 commit comments