2016-08-10 77 views
0

我有一個viewA包含一個GLKView和子視圖作爲UIImageView。如何將viewA保存到圖像?我使用這個代碼,工作良好的任何形式的看法,但GLKView如何快照視圖包含GLKView

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

    UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); 

    UIGraphicsEndImageContext(); 

    return img; 

} 

回答

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();