保存到文件
//************** 存图片 *******************
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",@"jietu"]]; // 保存文件的名称
NSLog(@"filePath = %@",filePath);
//UIImagePNGRepresentation方法将p_w_picpath对象转为NSData对象
//写入文件中
BOOL result = [UIImagePNGRepresentation(p_w_picpath)writeToFile: filePath atomically:YES];
NSLog(@"result = %d",result);
保存到相册
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
//************** 存图片 *******************
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",@"jietu"]]; // 保存文件的名称
NSLog(@"filePath = %@",filePath);
//UIImagePNGRepresentation方法将p_w_picpath对象转为NSData对象
//写入文件中
BOOL result = [UIImagePNGRepresentation(p_w_picpath)writeToFile: filePath atomically:YES];
NSLog(@"result = %d",result);
2 保存到相册
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);