您的位置:首页 > 移动开发 > IOS开发

iOS中截取当前屏幕,并保存图片的代码例子

2013-06-28 13:57 537 查看
UIGraphicsBeginImageContext(self.view.bounds.size);     //currentView 当前的view  创建一个基于位图的图形上下文并指定大小为 
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];//renderInContext呈现接受者及其子范围到指定的上下文 
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();//返回一个基于当前图形上下文的图片    
UIGraphicsEndImageContext();//移除栈顶的基于当前位图的图形上下文   
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);//然后将该图片保存到图片图


本文出自 “7087095” 博客,请务必保留此出处http://7097095.blog.51cto.com/7087095/1228332
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: