iOS截屏可以通过的代码来实现:// 创建一个屏幕大小的图片上下文
iOS截屏可以通过的代码来实现:
// 创建一个屏幕大小的图片上下文
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 0);
// 获取当前上下文
CGContextRef context = UIGraphicsGetCurrentContext();
// 将控制器的view的layer渲染到上下文中
[self.view.layer renderInContext:context];
// 从当前上下文中获取图片
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
// 结束上下文
UIGraphicsEndImageContext();
// 将图片保存到相册
UIImageWriteToSavedPhotosAl(image, nil, nil, nil);
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(63条)