2011-12-05 59 views
3

我试图采取2 - 3视图的iPad屏幕快照。 我可以做到这一点。转换屏幕快照

现在什么我的问题是,当我在横向模式M,我只是transformrotate一个视图与

CGAffineTransform transform; 
transform = CGAffineTransformMakeRotation(M_PI/2); 
imgPlayBoard.transform = transform; 

现在,当我走快照,然后在图像视图图像出现肖像。 发生了什么我无法得到它。我正在使用以下功能拍摄快照。

-(UIImage *)saveImage{ 

UIGraphicsBeginImageContext(imgPlayBoard.frame.size); 
[imgPlayBoard.layer renderInContext:UIGraphicsGetCurrentContext()]; 
[imagesView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
[drawBoard.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage * resultingImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIImageWriteToSavedPhotosAlbum(resultingImage, nil, nil, nil); 
UIGraphicsEndImageContext(); 
return resultingImage; 
} 

这是我得到的图像。快照中的图像大小相同,但所有ape都是白色。

+0

检查,如果这有助于http://stackoverflow.com/questions/2831576/iphone-ipad-application-taking-screen-shot –

+0

@AnkitSrivastava不全的观点是旋转,只有绿色背景旋转。这样,它不工作 – DivineDesert

回答

3

好的.. 我自己找到了解决方案。 所有工作正常。但是,由于我正在转换一个图像视图,然后将其渲染到上下文中,因此它将使用imageview的原始图像来丢弃转换。所以我所做的就是在图像中我想要的所有三种视图,我将它们添加到UIView中,然后拍摄该视图的快照。 这解决了我的问题。 :) 所以现在我的函数如下图所示

-(UIImage *)saveImage{ 
    UIGraphicsBeginImageContext(imgPlayBoard.frame.size); 
    [containerView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    UIImage * resultingImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return resultingImage; 
}