#define kKeyWindow [UIApplication sharedApplication].keyWindow
UIGraphicsBeginImageContext(kKeyWindow.bounds.size);
[kKeyWindow.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *dataImage = UIImageJPEGRepresentation(image, 0.5);
UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
BOOL iss = [dataImage writeToFile:@"/Users/apple/Desktop/未命名文件夹/i.png" atomically:YES];