iPhone:我可以保存屏幕或截屏到特定的视图区域

时间:2010-12-19 11:37:20

标签: iphone

在我的屏幕上有一个图像,我必须通过截图保存此图像。是否还有其他方法可以保存图像的特定区域?

如果有方法,请用一个简单的例子来指导我。

3 个答案:

答案 0 :(得分:1)

如果您需要一种编程方式来实现这一点,您可以使用:

[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:[view bounds]]];

答案 1 :(得分:1)

以下代码将允许您只抓取屏幕的一部分,您可以适应全屏

    CGRect screenRect = CGRectMake(0, 0, 200, 200);
UIGraphicsBeginImageContext(screenRect.size);

CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextFillRect(ctx, screenRect);

[self.view.layer renderInContext:ctx];

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

    //if you want to save this image to the photo album uncomment the next line
//UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);
UIGraphicsEndImageContext();

如果您只是想获得截图,只需按住主页和顶部按钮,每次进行时都会在相册中放置屏幕截图

答案 2 :(得分:0)

尝试同时按住主屏幕并关闭/关闭电源按钮。