Is it possible to get a UIImage from a UIView created with snapshotViewAfterScreenUpdates?
A UIView returned from snapshotViewAfterScreenUpdates looks fine when added as a subview, but the following produces a black image:
UIView *snapshotView = [someView snapshotViewAfterScreenUpdates:YES];
UIImage *snapshotImage = [self imageFromView:snapshotView];
- (UIImage *)imageFromView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0.0);
// [view.layer renderInContext:UIGraphicsGetCurrentContext()]; // <- same result...
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
It is of course possible to get the image without relying on snapshotViewAfterScreenUpdates:
UIImage *snapshotImage = [self imageFromView:someView];
Unfortunately, when capturing a complex view, drawViewHierarchyInRect can't match the speed of snapshotViewAfterScreenUpdates. I was hoping that it would be faster to get the UIImage from a view created by snapshotViewAfterScreenUpdates, is this possible?