我有一个水平滚动的集合视图。我需要从集合视图的当前可见部分创建一个 UIImageView。
为此,我通常使用以下方法:
+ (UIImageView *) imageCopyOfView:(UIView *)inputView
{
UIGraphicsBeginImageContext(inputView.bounds.size);
[inputView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *retView = [[UIImageView alloc] initWithImage:viewImage];
return retView;
}
但它在滚动后不适用于集合视图,因为它似乎正在获取已从屏幕滚动的视图的一部分