美文网首页
oc中获取当前页面的截图

oc中获取当前页面的截图

作者: itclimb | 来源:发表于2017-02-15 09:30 被阅读196次
oc

UIGraphicsBeginImageContext(self.view.bounds.size);    //currentView 当前的view  创建一个基于位图的图形上下文并指定大小为当前的View

[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];//renderInContext呈现接受者及其子范围到指定的上下文

UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();//返回一个基于当前图形上下文的图片

UIGraphicsEndImageContext();//移除栈顶的基于当前位图的图形上下文

UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);//然后将该图片保存到图片库

相关文章

网友评论

      本文标题:oc中获取当前页面的截图

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