文章目录
  1. 1. Look At Me!

Look At Me!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* 存图片到本地
*
* @param suffix @"xxx.png"
* @param image <#image description#>
*/
+(void)saveImageToDomainsWithDirectorystringByAppendingPathComponent:(NSString *)suffix WithImage:(UIImage *)image{
//JEPG格式
//压缩图片
NSData *imagedata=UIImageJPEGRepresentation(image,1.0);

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

NSString *documentsDirectory=[paths objectAtIndex:0];

NSString *savedImagePath=[documentsDirectory stringByAppendingPathComponent:suffix];
MYLog(@"%@",savedImagePath);
[imagedata writeToFile:savedImagePath atomically:YES];
}
/**
* 取回图片
*
* @param suffix 图片名字
*
* @return
*/
+ (UIImage *)fetchImageWithDirectorystringByAppendingPathComponent:(NSString *)suffix{
NSString *aPath3=[NSString stringWithFormat:@"%@/Documents/%@.png",NSHomeDirectory(),suffix];
UIImage *imgFromUrl3=[[UIImage alloc]initWithContentsOfFile:aPath3];
UIImageView* imageView3=[[UIImageView alloc]initWithImage:imgFromUrl3];
return imageView3.image;
}
文章目录
  1. 1. Look At Me!