将一个UIView对象的内容保存为UIImage

+ (UIImage*)imageFromView:(UIView*)view{   
 
02     
 
03 UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, view.layer.contentsScale);   
 
04     
 
05 [view.layer renderInContext:UIGraphicsGetCurrentContext()];   
 
06     
 
07 UIImage *image = UIGraphicsGetImageFromCurrentImageContext();   
 
08     
 
09 UIGraphicsEndImageContext();   
 
10     
 
11 return image;   
 
12     
 
13 }  

 

posted on 2015-02-13 18:09  三十一  阅读(287)  评论(0编辑  收藏  举报

导航