iphone 保存图片到相册照片库

已知图片保存到相册

UIImageWriteToSavedPhotosAlbum([UIImage imageNamed:photoName], self@selector(image:didFinishSavingWithError:contextInfo:), nil);


- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo

{

UIAlertView *alert;

    if (error == nil)

{

alert = [[UIAlertView allocinitWithTitle:nil message:@"This picture has been saved to your photo album.Picture Saved!" delegate:nilcancelButtonTitle:@"OK." otherButtonTitles:nil];

[alert show];

[alert release];

}

else

{

alert = [[UIAlertView allocinitWithTitle:nil message:@"Please try it again later.Saving Failed" delegate:nilcancelButtonTitle:@"OK." otherButtonTitles:nil];

[alert show];

[alert release];

}

}


 

保存当前视图:

#import <QuartzCore/QuartzCore.h>

UIGraphicsBeginImageContext(currentView.bounds.size); //currentView当前的view

[currentView.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

UIImageWriteToSavedPhotosAlbum(viewImage, nilnilnil);

相关文章
相关标签/搜索
每日一句
    每一个你不满意的现在,都有一个你没有努力的曾经。
公众号推荐
   一个历史类的公众号,欢迎关注
一两拨千金