我有一个viewA,它包含一个GLKView和子视图作为UIImageView。如何将viewA快照到图像?我使用此代码,适用于任何类型的视图,但GLKView
- (UIImage *) takeSnapshot
{
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, [[UIScreen mainScreen] scale]);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
答案 0 :(得分:0)
它帮助我:
GLKView *glView = ...;
UIImage *img = [glView snapshot];
并将其绘制到您需要的上下文中,例如:
CGContextRef context = UIGraphicsGetCurrentContext();
CGPoint point = glView.frame.origin;
[img drawAtPoint:point blendMode:kCGBlendModeNormal alpha:1];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();