Skip to content

Commit c18a19b

Browse files
author
Justin Martin
authored
Merge pull request #1289 from banjun/fix-ios17-black-screenshot-due-to-keyboard
iOS 17 - fix black screenshots after using a keyboard
2 parents 7a06351 + da732b5 commit c18a19b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/KIF/Additions/UIApplication-KIFAdditions.m

+9-1
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,22 @@ - (BOOL)writeScreenshotForLine:(NSUInteger)lineNumber inFile:(NSString *)filenam
178178
}
179179
return NO;
180180
}
181-
181+
182+
UIWindow *keyboardWindow = [self keyboardWindow];
183+
182184
UIGraphicsBeginImageContextWithOptions([[windows objectAtIndex:0] bounds].size, YES, 0);
183185
for (UIWindow *window in windows) {
184186
//avoid https://github.com/kif-framework/KIF/issues/679
185187
if (window.hidden) {
186188
continue;
187189
}
188190

191+
if (@available(iOS 17.0, *)) {
192+
if (window == keyboardWindow) {
193+
continue;
194+
}
195+
}
196+
189197
if ([window respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) {
190198
[window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES];
191199
} else {

0 commit comments

Comments
 (0)