Some times we don't get a correct screenshot of an iOS device. Specially when we apply some transform or animation. If you are applying affine transform or 3dTransform to an object and hoping for a perfect screenshot with same transform value then you are seriously in trouble. But don't worry about it. After spending hours on this issue finally I have got solution. Feeling glad to share this with you.
- (UIImage *)snapshot:(UIView *)view{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.0);
// This will Render your device snapshot into the image context
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
// Now this will help you to get the image from the context
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
Hope this would help you to get a perfect screenshot.
Happy Coding!!!
0 Comment(s)