博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
保存图片
阅读量:7197 次
发布时间:2019-06-29

本文共 1167 字,大约阅读时间需要 3 分钟。

保存到文件

//************** 存图片 *******************

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);

    NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",@"jietu"]];   // 保存文件的名称

    NSLog(@"filePath = %@",filePath);

    //UIImagePNGRepresentation方法将image对象转为NSData对象

    //写入文件中

    BOOL result = [UIImagePNGRepresentation(image)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方法将image对象转为NSData对象

    //写入文件中

    BOOL result = [UIImagePNGRepresentation(image)writeToFile: filePath atomically:YES]; 

    NSLog(@"result = %d",result);

2 保存到相册

UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

本文转自 卓行天下  51CTO博客,原文链接:http://blog.51cto.com/9951038/1772568,如需转载请自行联系原作者
你可能感兴趣的文章
我的友情链接
查看>>
java String类详解
查看>>
Json Web Token身份认证
查看>>
Jersey 2.x 探索新建的工程
查看>>
2个页面监听变化
查看>>
循环结构
查看>>
我的友情链接
查看>>
在TabBarController中使用SplitViewController
查看>>
MicroPython开发板之TPYBoard:用Python语言控制单片机
查看>>
CFS终于敲定了
查看>>
SpringMVC权限管理
查看>>
java 多线程之取消与关闭
查看>>
网络研讨会的邀请:网络公开课_守护好数据库的备份信息
查看>>
使程序在Linux下后台运行
查看>>
关于赋值语句的一点看法
查看>>
windows版本的Emacs 无法显示图片的解决方法
查看>>
Discuz! 经典加密解密函数(带详解)
查看>>
JVM内存结构和6大区域
查看>>
centos6 Docker桥接到主机所在的内网
查看>>
C++ 动态内存
查看>>