天天看點

儲存圖檔

儲存到檔案

//************** 存圖檔 *******************

    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);

2 儲存到相冊

本文轉自 卓行天下  51CTO部落格,原文連結:http://blog.51cto.com/9951038/1772568,如需轉載請自行聯系原作者

繼續閱讀