Skip to content
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

feat: replaced depricated apis with new ones for ui image #515

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ios/RNViewShot.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ - (dispatch_queue_t)methodQueue
scrollView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height);
}

UIGraphicsBeginImageContextWithOptions(size, NO, 0);
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size];

if (renderInContext) {
// this comes with some trade-offs such as inability to capture gradients or scrollview's content in full but it works for large views
Expand All @@ -117,8 +117,8 @@ - (dispatch_queue_t)methodQueue
// this doesn't work for large views and reports incorrect success even though the image is blank
success = [rendered drawViewHierarchyInRect:(CGRect){CGPointZero, size} afterScreenUpdates:YES];
}
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {}];

if (snapshotContentContainer) {
// Restore scroll & frame
Expand Down