@@ -118,52 +118,21 @@ final class NavigationTransitionAnimatorProvider: NSObject, UIViewControllerAnim
118118 ) -> ( fromView: AnimatorTransientView , toView: AnimatorTransientView ) ? {
119119 guard
120120 let fromUIView = context. view ( forKey: . from) ,
121- let fromUIViewSnapshot = fromUIView. snapshotView ( afterScreenUpdates: false ) ,
122- let toUIView = context. view ( forKey: . to) ,
123- let toUIViewSnapshot = toUIView. snapshotView ( afterScreenUpdates: true )
121+ let toUIView = context. view ( forKey: . to)
124122 else {
125123 return nil
126124 }
127125
128- let fromView = AnimatorTransientView ( fromUIViewSnapshot)
129- let toView = AnimatorTransientView ( toUIViewSnapshot)
130-
131126 let container = context. containerView
132- fromUIView. removeFromSuperview ( )
133- container. addSubview ( fromUIViewSnapshot)
134127 switch operation {
135128 case . push:
136- container. insertSubview ( toUIViewSnapshot , aboveSubview: fromUIViewSnapshot )
129+ container. insertSubview ( toUIView , aboveSubview: fromUIView )
137130 case . pop:
138- container. insertSubview ( toUIViewSnapshot , belowSubview: fromUIViewSnapshot )
131+ container. insertSubview ( toUIView , belowSubview: fromUIView )
139132 }
140133
141- // this is a hack that uses a 0-sized container to ensure that
142- // toView is added to the view hierarchy but not visible,
143- // in order to have toViewSnapshot sized properly
144- let invisibleContainer = UIView ( )
145- invisibleContainer. clipsToBounds = true
146- invisibleContainer. addSubview ( fromUIView)
147- invisibleContainer. addSubview ( toUIView)
148- container. addSubview ( invisibleContainer)
149-
150- animator. addCompletion { [ weak container, weak fromUIView, weak toUIView] _ in
151- guard
152- let container = container,
153- let fromUIView = fromUIView,
154- let toUIView = toUIView
155- else {
156- return
157- }
158- for subview in container. subviews {
159- subview. removeFromSuperview ( )
160- }
161- if context. transitionWasCancelled {
162- container. addSubview ( fromUIView)
163- } else {
164- container. addSubview ( toUIView)
165- }
166- }
134+ let fromView = AnimatorTransientView ( fromUIView)
135+ let toView = AnimatorTransientView ( toUIView)
167136
168137 handler ( fromView, toView, operation, container)
169138
0 commit comments