码迷,mamicode.com
首页 > 其他好文 > 详细

图片的读取

时间:2014-09-24 13:51:06      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:style   color   io   ar   for   文件   div   sp   on   

 // 图片路径
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    
    NSString *imagePath = [path stringByAppendingPathComponent:@"iconImage.png"];
    
    /*读取入图片*/
    //因为拿到的是个路径,所以把它加载成一个data对象
    NSData *data = [NSData dataWithContentsOfFile:imagePath];

    UIImage *image = [UIImage imageWithData:data];
 
  // 图片路径
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) lastObject];
    
    NSString *imagePath=[path stringByAppendingPathComponent:@"iconImage.png"];
    // 将图片写到Documents文件中
    [UIImagePNGRepresentation(image) writeToFile:imagePath atomically:YES
];

图片的读取

标签:style   color   io   ar   for   文件   div   sp   on   

原文地址:http://www.cnblogs.com/Milo-CTO/p/3990182.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!