Skip to content

Commit

Permalink
Use UIGraphicsImageRenderer instead of creating our own graphics cont…
Browse files Browse the repository at this point in the history
…ext (#95)
  • Loading branch information
Reid Main committed Jun 28, 2019
1 parent 3571487 commit d0ac08b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions FBSnapshotTestCase/Categories/UIImage+Snapshot.m
Expand Up @@ -56,11 +56,11 @@ + (UIImage *)fb_imageForView:(UIView *)view
NSAssert1(CGRectGetWidth(bounds), @"Zero width for view %@", view);
NSAssert1(CGRectGetHeight(bounds), @"Zero height for view %@", view);

UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
UIGraphicsImageRenderer *graphicsImageRenderer = [[UIGraphicsImageRenderer alloc] initWithSize:bounds.size];

UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImage *snapshot = [graphicsImageRenderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {
[view drawViewHierarchyInRect:bounds afterScreenUpdates:YES];
}];

if (removeFromSuperview) {
[view removeFromSuperview];
Expand Down

0 comments on commit d0ac08b

Please sign in to comment.