Objective c 屏幕捕获超出屏幕范围
我使用UIGraphicsBeginImageContextWithOptions来获取当前显示的屏幕UITable的屏幕抓取 这是我的密码:Objective c 屏幕捕获超出屏幕范围,objective-c,uiimage,calayer,uigraphicscontext,Objective C,Uiimage,Calayer,Uigraphicscontext,我使用UIGraphicsBeginImageContextWithOptions来获取当前显示的屏幕UITable的屏幕抓取 这是我的密码: UIGraphicsBeginImageContextWithOptions(self.view.frame.size, self.view.opaque, 0.0); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsG
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
然后我使用图像对象作为屏幕抓取
我的问题是,我想屏幕抓取包括额外的100像素的当前未显示的数据,它将显示,如果我向下滚动
我该怎么做
- (IBAction) renderScrollViewToImage
{
UIImage* image = nil;
UIGraphicsBeginImageContext(_scrollView.contentSize);
{
CGPoint savedContentOffset = _scrollView.contentOffset;
CGRect savedFrame = _scrollView.frame;
_scrollView.contentOffset = CGPointZero;
_scrollView.frame = CGRectMake(0, 0, _scrollView.contentSize.width, _scrollView.contentSize.height);
[_scrollView.layer renderInContext: UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
_scrollView.contentOffset = savedContentOffset;
_scrollView.frame = savedFrame;
}
UIGraphicsEndImageContext();
if (image != nil) {
[UIImagePNGRepresentation(image) writeToFile: @"/tmp/test.png" atomically: YES];
system("open /tmp/test.png");
}
}
参考但这将捕获整个内容。我只想要当前可见的+100像素。另外,我会将此添加到我正在使用UITable的描述中。