标签:
第一步:添加 AssetsLibrary.framework 框架
第二步:需要使用的类里面导入头文件 #import <AssetsLibrary/AssetsLibrary.h>
第三步:保存网络图片到本地
- (void)viewDidLoad { [super viewDidLoad]; UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://pic25.nipic.com/20121209/9252150_194258033000_2.jpg"]]]; [self saveImage:image]; } - (void)saveImage:(UIImage*)image{ ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; [library writeImageToSavedPhotosAlbum:[image CGImage] orientation:(ALAssetOrientation)image.imageOrientation completionBlock:^(NSURL *assetURL, NSError *error) { if (error) { NSLog(@"Save image fail:%@",error); }else{ NSLog(@"Save image succeed."); } }]; }
标签:
原文地址:http://my.oschina.net/linxiaoxi1993/blog/498202