图片的读取

 // 图片路径
    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
];
posted @ 2014-09-24 11:03  Milo_D  阅读(161)  评论(0编辑  收藏  举报