截图

来源:互联网 发布:c语言delay用法 编辑:程序博客网 时间:2024/04/30 19:34

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





0 0
原创粉丝点击