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