我遇到了一个非常奇怪的情况...我试图通过调用下面的drawViewHierarchyInRect: afterScreenUpdates:
方法来捕获滚动视图中(其contentSize
超出屏幕边界三倍)的内容:
+ (UIImage *) imageFromScrollView: (UIScrollView *) scrollView {
UIGraphicsBeginImageContext(size);
[view drawViewHierarchyInRect: CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height)
afterScreenUpdates: YES];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
该应用适用于:iPhone设备、iPhone和iPad模拟器,但在iPad设备上不可用。您是否遇到过类似的问题?我会非常感激任何帮助!
UIGraphicsGetCurrentContext()
和UIGraphicsBeginImageContext()
。之前,我使用了你提到的renderInContext:
方法,但我想利用iOS 7中的新方法,这似乎更快。 - jaaakub