欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS 沙盒圖片保存讀取實(shí)例

 更新時(shí)間:2017年12月29日 15:04:39   作者:小手一背愛(ài)誰(shuí)誰(shuí)  
下面小編就為大家分享一篇iOS 沙盒圖片保存讀取實(shí)例,具有很的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

實(shí)例如下所示:

//保存圖片
-(void)saveImageDocuments:(UIImage *)image{
  //拿到圖片
  UIImage *imagesave = image;
  NSString *path_sandox = NSHomeDirectory();
  //設(shè)置一個(gè)圖片的存儲(chǔ)路徑
  NSString *imagePath = [path_sandox stringByAppendingString:@"/Documents/test.png"];
  //把圖片直接保存到指定的路徑(同時(shí)應(yīng)該把圖片的路徑imagePath存起來(lái),下次就可以直接用來(lái)?。?
  [UIImagePNGRepresentation(imagesave) writeToFile:imagePath atomically:YES];
}
// 讀取并存貯到相冊(cè) 
-(UIImage *)getDocumentImage{
  // 讀取沙盒路徑圖片
  NSString *aPath3=[NSString stringWithFormat:@"%@/Documents/%@.png",NSHomeDirectory(),@"test"];
  // 拿到沙盒路徑圖片
  UIImage *imgFromUrl3=[[UIImage alloc]initWithContentsOfFile:aPath3];
  // 圖片保存相冊(cè)
  UIImageWriteToSavedPhotosAlbum(imgFromUrl3, self, nil, nil);
  return imgFromUrl3;
}

以上這篇iOS 沙盒圖片保存讀取實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論