使用正确的zoomScale将UIScrollView捕获到图像

时间:2013-05-08 10:07:42

标签: ios objective-c cocoa-touch uiscrollview

我正在使用此代码拍摄UIScrollView的快照。我的问题是快照将始终采用UIScrollView的1.0f缩放比例,而我想要快照UIScrollView中的所有内容。我怎么能做到这一点?

CGRect rect = [viewToCapture bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[viewToCapture.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return capturedImage;

1 个答案:

答案 0 :(得分:0)

您可以查看以下网址:

https://stackoverflow.com/a/15804107/1443976