这是我的代码,用于截取我的scrollview的截图:
UIImage* image = nil;
UIGraphicsBeginImageContextWithOptions(_scrollView.contentSize, _scrollView.opaque, 0.0);
{
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()];
}
我试过这个没有成功:
[_scrollView drawViewHierarchyInRect:_scrollView.bounds afterScreenUpdates:YES];