0

Is there any way to capture a UIView to UIImage which is not currently visible or it is out of the frame. Below the code I am using now:

UIGraphicsBeginImageContextWithOptions(_myView.bounds.size, _myView.opaque, 0.0f);
[theView drawViewHierarchyInRect:_myView.bounds afterScreenUpdates:NO];
UIImage * snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
christijk
  • 1,753
  • 18
  • 26

1 Answers1

1

Try this-

-(UIImage *)imageFromView:(UIView *)myView{ 
     UIGraphicsBeginImageContextWithOptions(myView.bounds.size, myView.opaque, [UIScreen mainScreen].scale); 
     [myView.layer renderInContext:UIGraphicsGetCurrentContext()];
     UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
     UIGraphicsEndImageContext();
     return image;
  }
nilam_mande
  • 931
  • 7
  • 14