-(void)bnt{
//保存整个屏幕的图片
UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];
DebugLog(@"wid= %@",screenWindow);
UIGraphicsBeginImageContext(screenWindow.frame.size);
[self.navigationController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//viewImage:保存的图片
UIImageWriteToSavedPhotosAlbum(viewImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
// UIImageWriteToSavedPhotosAlbum(_imageCodeView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
//保存图片到相册的回调函数
-(void) image: (UIImage *)image didFinishSavingWithError: (NSError *)error
contextInfo: (void *) contextInfo{
NSString *msg=nil;
if (error == nil) {
[self showMessage:@"你的二维码已经保存到相册,赶快分享给朋友吧!"];
}
else {
[error.userInfo objectForKey:@""];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)
{
ALAuthorizationStatus authorizationStatus = [ALAssetsLibrary authorizationStatus];
if (authorizationStatus == ALAuthorizationStatusDenied) {
msg = @"App没有权限来访问您的照片.\r\n您可以在“隐私设置”中启用访问";
} else {
msg = @"保存失败";
}
}
else
{
msg = @"保存失败";
}
}
// NSLog(@"msg=%@",msg);
// UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
// [alertView show];
}