第一种截屏:
CGImageRef UIGetScreenImage();
CGImageRef img = UIGetScreenImage();
UIImage *scImage = [UIImage imageWithCGImage:img];
UIImageWriteToSavedPhotosAlbum(scImage, nil, nil, nil);
第二种截屏:
- (UIImage *)imageFromView
{
UIGraphicsBeginImageContext(self.view.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
但是不能在相机界面截图,截取出来的图片是空白的。
网友评论