简体   繁体   English

集合视图单元动画

[英]Collection view Cell Animations

I am trying to animate UICollectionviewCells as they are created. 我正在尝试为UICollectionviewCells创建动画。 I wanted to give each collectionviewcell a frame whose origin would be outside the phone and then I try to animate them, the way I wanted to do this was to use animate with duration and save their actual frames so that I can have the collectionviewCells animate to the so called "actual frames", the problem now is that, so I make one collectionViewcell in one section, so every collectionviewcell has "0" as its origin for the "actual frame", I won't be able to get the correct frames on the screen to animate a uicollectionview cell too. 我想给每个collectionviewcell一个框架,其起源将在电话之外,然后尝试对其进行动画处理,我想这样做的方法是对时长使用动画并保存其实际帧,以便使collectionviewCells可以进行动画处理。所谓的“实际框架”,现在的问题是,因此我在一个部分中制作了一个collectionViewcell,因此每个collectionviewcell的“实际框架”都以“ 0”作为它的来源,我将无法获得正确的屏幕上的框架也可以为uicollectionview单元设置动画。 Would anyone have any suggestion for me to achieve the animation? 有人会建议我实现动画吗?

You may want to check this link: http://www.objc.io/issue-12/collectionview-animations.html . 您可能需要检查以下链接: http : //www.objc.io/issue-12/collectionview-animations.html

The standardized idea is to subclass UICollectionViewLayout and then implement the method initialLayoutAttributesForAppearingItemAtIndexPath: to provide the initial positioning properties of the cells. 标准化的想法是子类化UICollectionViewLayout ,然后实现方法initialLayoutAttributesForAppearingItemAtIndexPath:以提供单元格的初始定位属性。

PS Other animations (when you remove a cell or when you rotate your device) are also talked about in the post. PS在帖子中还讨论了其他动画(当您删除单元格或旋转设备时)。 Read them if you are interested. 如果有兴趣,请阅读它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM