截图

2016-08-07  本文已影响11人  金歌漫舞

1.开启图片上下文

UIGraphicsBeginImageContextWithOptions(_drawView.frame.size, NO, 0);  

2.获取当前上下文

CGContextRef context = UIGraphicsGetCurrentContext();

3.把drawView的layer 渲染到当前上下文中,drawView为想截取图片,一般为自定义的View

[_drawView.layer renderInContext:context];  

4.从当前的图片上下文中获取图片

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();  

5.关闭上下文

UIGraphicsEndImageContext();  

6.保存到相册

UIImageWriteToSavedPhotosAlbum(image, nil , nil, nil); 
上一篇 下一篇

猜你喜欢

热点阅读