拍摄隐藏的UIView的快照 [英] Take a snapshot of a hidden UIView

查看:41
本文介绍了拍摄隐藏的UIView的快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对隐藏视图进行快照,但是遇到了一些问题。如果我尝试快速取消隐藏,拍摄快照然后重新隐藏,有时会在屏幕上出现快速闪烁的感觉,这很刺耳。

I'm trying to take a snapshot of a hidden view but am running into several issues. If I try unhiding it quickly, taking a snapshot, and then rehiding it, I sometimes get a quick flicker on the screen that is pretty jarring.

toCollectionViewCell.hidden = NO;
UIView *toPlaceHolderSnapshot = [toCollectionViewCell resizableSnapshotViewFromRect:toCollectionViewCell.bounds afterScreenUpdates:YES withCapInsets:UIEdgeInsetsZero];
toCollectionViewCell.hidden = YES;

我很确定闪烁是由afterScreenUpdates:YES引起的,但我无法想象

I'm pretty sure the flicker is caused by the afterScreenUpdates:YES, but I can't imagine that is intended behavior.

我也尝试过将单元格/视图移出屏幕而不是隐藏它,但是我不确定何时可以重新加载该单元格并因此过早地移回原处。

I've also tried moving the cell/view off screen instead of hiding it, but I can't be certain when that cell might be reloaded and therefore moved back into its place prematurely.

有没有办法对隐藏视图进行快照或更巧妙的方法来实现此目的?在自定义过渡动画期间,我需要此功能,在该动画中,我将集合视图单元格从集合视图中拉出,然后在关闭时将其返回到位。我正在制作之前/之后状态的快照,然后在动画过程中在两者之间切换。

Is there a way to take a snapshot of a hidden view or a more clever way to achieve this? I need this functionality during a custom transition animation where I am pulling a collection view cell out of the collection view and then returning it back into place on dismiss. I am taking snapshots of the before/after state and then transitioning between the two during the animation.

谢谢!

推荐答案

向视图层次结构中添加一个额外的容器视图。隐藏该容器将具有相同的视觉效果,但是您将可以轻松地快照该容器的内容。

Add an extra container view to your view hierarchy. Hiding the container will have the same visual effect, but you'll be able to snapshot the content of a container with ease.

这篇关于拍摄隐藏的UIView的快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆