【发布时间】:2023-03-09 10:09:01
【问题描述】:
我有一个水平滚动的集合视图。我需要从集合视图的当前可见部分创建一个 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;
}
但它在 Collection View 滚动后无法使用,因为它似乎正在获取已从屏幕上滚动的视图的一部分
【问题讨论】:
标签: ios uicollectionview uigraphicscontext