Skip to content

Commit

Permalink
Merge pull request #515 from vibhor-d11/fix/ui-image-api
Browse files Browse the repository at this point in the history
feat: replaced depricated apis with new ones for ui image
  • Loading branch information
gre authored Apr 5, 2024
2 parents b9d66e2 + 4ea3b8a commit 1881b46
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 1881b46

Please sign in to comment.