0

I have a viewA that contains a GLKView and subviews as UIImageView. How can I snapshot hold of viewA to an image? I'm using this code, work good for any kind of view but GLKView

- (UIImage *) takeSnapshot
{
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, [[UIScreen mainScreen] scale]);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return img;

}
genpfault
  • 51,148
  • 11
  • 85
  • 139
Q.u.a.n.g L.
  • 1,564
  • 1
  • 12
  • 27

1 Answers1

0

its help me:

GLKView *glView = ...;
UIImage *img = [glView snapshot];

and draw it to context what you need, for example:

CGContextRef context = UIGraphicsGetCurrentContext();
CGPoint point = glView.frame.origin;
[img drawAtPoint:point blendMode:kCGBlendModeNormal alpha:1];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Bogdan Evsenev
  • 851
  • 9
  • 16