我想将图像保存在特定文件夹中的图库中。当我单击保存时,我正在使用此代码保存图像
- (IBAction)saveImageToGallery:(id)sender {
NSLog(@"SaveImageToGallery");
/*
-----------------------------------------------------------------------
THis will hide button and take screen shot then will show buttons again
-----------------------------------------------------------------------
*/
[AddImagesToCanvasView setHidden:YES];
[ShareOnCanvas setHidden:YES];
[CanvasButtonForRatio setHidden:YES];
for(UIButton *b in self.view.subviews) {
if([b isKindOfClass:[UIButton class]]) {
b.hidden = YES;
}
}
UIGraphicsBeginImageContext(self.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
for(UIButton *b in self.view.subviews) {
if([b isKindOfClass:[UIButton class]]) {
b.hidden = NO;
}
}
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
}
我希望当我点击保存而不是打开照片时,我可以创建新相册或点击现有相册并将该图像保存在该相册中。我将如何做到这一点。这可能吗?