Skip to content

Commit

Permalink
Merge pull request #1289 from banjun/fix-ios17-black-screenshot-due-t…
Browse files Browse the repository at this point in the history
…o-keyboard

iOS 17 - fix black screenshots after using a keyboard
  • Loading branch information
Justin Martin authored Oct 11, 2023
2 parents 7a06351 + da732b5 commit c18a19b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Sources/KIF/Additions/UIApplication-KIFAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,22 @@ - (BOOL)writeScreenshotForLine:(NSUInteger)lineNumber inFile:(NSString *)filenam
}
return NO;
}


UIWindow *keyboardWindow = [self keyboardWindow];

UIGraphicsBeginImageContextWithOptions([[windows objectAtIndex:0] bounds].size, YES, 0);
for (UIWindow *window in windows) {
//avoid https://github.com/kif-framework/KIF/issues/679
if (window.hidden) {
continue;
}

if (@available(iOS 17.0, *)) {
if (window == keyboardWindow) {
continue;
}
}

if ([window respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) {
[window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES];
} else {
Expand Down

0 comments on commit c18a19b

Please sign in to comment.