0

我正在处理贺卡的应用,我已经拍摄了屏幕截图并保存在图库中,因此请提供适用于我的代码的任何建议和源代码

4

1 回答 1

0

Like so:

- (UIImage *) captureScreen {
    UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
    CGRect rect = [keyWindow bounds];
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [keyWindow.layer renderInContext:context];   
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;
}

Then save the image to camera roll using the following tutorial http://mobiledevelopertips.com/camera/save-an-image-to-camera-roll.html

于 2012-05-21T14:42:27.613 回答