Skip to content

Commit

Permalink
Snapshot to use key window size if possible
Browse files Browse the repository at this point in the history
Summary:
Use the application key window bounds if possible.
In the case where the application is not using the entire screen,
like in Split View on an iPad, the running application is
not using the entire screen thus the snapshot stretches to
fill the screen size which is incorrect.

Reviewed By: LukeDefeo

Differential Revision: D47793033

fbshipit-source-id: d6c7932d35bad13752713772d078f94bad530b09
  • Loading branch information
lblasa authored and facebook-github-bot committed Jul 26, 2023
1 parent f854e9f commit aba5088
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@

UIImage* UIDApplicationSnapshot(UIApplication* application, NSArray* windows) {
CGSize size = [UIScreen mainScreen].bounds.size;

// Use the application key window bounds if possible.
// In the case where the application is not using the entire screen,
// like in Split View on an iPad, the running application is
// not using the entire screen thus the snapshot stretches to
// fill the screen size which is incorrect.
if (application.keyWindow) {
size = application.keyWindow.bounds.size;
}

UIGraphicsImageRenderer* renderer =
[[UIGraphicsImageRenderer alloc] initWithSize:size];

Expand Down

0 comments on commit aba5088

Please sign in to comment.