-
Notifications
You must be signed in to change notification settings - Fork 554
Improve UIScreen Capture() support for complex views #1235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve UIScreen Capture() support for complex views #1235
Conversation
|
Hi @christianhelle, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! TTYL, DNFBOT; |
|
Hello! I'm the build bot for the Mono project. I need approval from a Mono team member to build this pull request. A team member should reply with "approve" to approve a build of this pull request, "whitelist" to whitelist this and all future pull requests from this contributor, or "build" to explicitly request a build, even if one has already been done. Contributors can ignore this message. |
|
approve |
rolfbjarne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good, except for a minor style issue: we use a space before the opening parenthesis in a method call. Could you please fix this (you've also changed it in the existing code you've re-indented due to the additional if clause)?
Also I don't think there are any backwards compatibility issues, and the new code is clearly rendering a better screenshot according to the provided screenshots.
|
Thanks for the input @rolfbjarne, I'll fix the styling issue you pointed out. I'm pretty sure that the method drawViewHierarchyInRect:afterScreenUpdates: was introduced in iOS 7.0 since it states that in the documentation page. If I didn't include the original implementation then calling I'm fine with replacing the old implementation but I wanted to tread carefully since this is my first time contributing to the product I thought I should consider backwards compatibility |
spouliot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 (modulo Rolf's comments)
Thanks for your contribution!
|
Build failure |
|
I updated my changes based on the comments by @rolfbjarne |
|
Build failure |
|
Test failures are unrelated (watchOS/System test failures filed as bug #47167). |
|
Thanks! |
|
Looking at this PR, we should also test that the UIView.Capture added in commit 7c51c3b @rolfbjarne what do you think? |
|
/cc @spouliot I forgot you ;) |
Use DrawViewHierarchy to capture a snapshot of the current screen
Use DrawViewHierarchy to capture a snapshot of the current screen
The current UIScreen Capture() method doesn't support complex views with multiple CA Layers (for example iCarousel). The changes here are in use in our apps in the AppStore with over half a million daily active users and no one has ever reported a bug regarding it. I kept the original code for backward compatibility as drawViewHierarchyInRect:afterScreenUpdates: was introduced in iOS 7.0. My changes were based from https://developer.apple.com/library/content/qa/qa1817/_index.html
Screenshot using original Capture() implementation:

Screenshot using the changes in this pull request:

The images above are from an app with a screen using iCarousel with 8 items containing both images and texts. I used the UIScreen Capture() method to capture this screen before opening another screen where I show it as the background image.
I unfortunately had to crop out the rest of the image due to corporate reasons, but the images provided above are enough to illustrate the problem. I can provide a video of the problem if needed as long as this video is not shared with the general public