@@ -93,20 +93,54 @@ class TransitionWithPresentationTests: XCTestCase {
93
93
XCTAssertEqual ( window. rootViewController!. presentedViewController? . view. frame,
94
94
transition. presentationFrame)
95
95
}
96
+
97
+ func testNoFramesModifiedWhenThereIsAPresentationView( ) {
98
+ let presentedViewController = UIViewController ( )
99
+ let transition = PresentationTransition ( )
100
+ let presentationView = UIView ( )
101
+ transition. presentationView = presentationView
102
+ presentedViewController. transitionController. transition = transition
103
+
104
+ let didComplete = expectation ( description: " Did complete " )
105
+ window. frame = CGRect ( x: 0 , y: 0 , width: 300 , height: 200 )
106
+ window. rootViewController!. present ( presentedViewController, animated: true ) {
107
+ didComplete. fulfill ( )
108
+ }
109
+
110
+ waitForExpectations ( timeout: 0.1 )
111
+
112
+ XCTAssertEqual ( window. rootViewController!. presentedViewController, presentedViewController)
113
+ XCTAssertEqual ( presentationView. frame, . zero)
114
+ XCTAssertEqual ( presentedViewController. view. frame, UIScreen . main. bounds)
115
+ }
96
116
}
97
117
98
118
final class TestingPresentationController : UIPresentationController {
99
119
var presentationFrame : CGRect ?
120
+ var presentationView : UIView ?
100
121
override var frameOfPresentedViewInContainerView : CGRect {
101
122
if let presentationFrame = presentationFrame {
102
123
return presentationFrame
103
124
}
104
125
return super. frameOfPresentedViewInContainerView
105
126
}
127
+
128
+ override var presentedView : UIView ? {
129
+ return presentationView
130
+ }
131
+
132
+ override func presentationTransitionWillBegin( ) {
133
+ super. presentationTransitionWillBegin ( )
134
+
135
+ if let presentationView = presentationView {
136
+ containerView? . addSubview ( presentationView)
137
+ }
138
+ }
106
139
}
107
140
108
141
final class PresentationTransition : NSObject , TransitionWithPresentation {
109
142
var presentationFrame : CGRect ?
143
+ var presentationView : UIView ?
110
144
111
145
func defaultModalPresentationStyle( ) -> UIModalPresentationStyle {
112
146
return . custom
@@ -116,6 +150,7 @@ final class PresentationTransition: NSObject, TransitionWithPresentation {
116
150
let presentationController =
117
151
TestingPresentationController ( presentedViewController: presented, presenting: presenting)
118
152
presentationController. presentationFrame = presentationFrame
153
+ presentationController. presentationView = presentationView
119
154
return presentationController
120
155
}
121
156
0 commit comments