截图

作者: 金歌漫舞 | 来源:发表于2016-08-07 17:56 被阅读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); 
    

    相关文章

      网友评论

          本文标题:截图

          本文链接:https://www.haomeiwen.com/subject/lpulsttx.html