【问题标题】:Transition between two UICollectionViewCells两个 UICollectionViewCell 之间的转换
【发布时间】:2013-06-27 18:12:22
【问题描述】:

我有一个使用流式布局的 UICollectionView。

最初它会在 iPad 屏幕上显示大约 5 X 5 的小单元。

我想要做的是平滑地更改为几乎全屏的单元格大小,单元格的布局更大,布局略有不同。

----------------
| |---| |---|  |
| |   | |   |  |
| |---| |---|  |
|              |
| |---| |---|  |
| |   | |   |  |
| |---| |---|  |
----------------

transitions to..
----------------
| |---------|  |
| |         |  |
| |         |  |
| |         |  |
| |---------|  |
|              |
| |---------|  |
----------------

目前我使用布尔值showLarge,当用户点击时我将其设置为YES (didSelectItemAtIndexPath)

然后我重新加载数据。

self.showLarge = YES;
[self.collectionView reloadData];

在我的cellForItemAtIndexPath 中,我根据布尔值加载适当的单元格:

 if (!self.showLarge)
 {
     SmallCell *smallCell ..
     etc
     return smallCell;
 } else
 {
     LargeCell *smallCell ..
     etc
     return largeCell;
 }

但是,这是一个突然的转变。

如何平滑地为新的自定义 UICollectionViewCell 制作动画?

【问题讨论】:

    标签: ios objective-c uicollectionview uicollectionviewcell


    【解决方案1】:

    您可以使用不同的UICollectionViewFlowLayout,然后动态更改集合视图的布局。这会给你一个漂亮的动画,而不需要重新加载任何东西。

    【讨论】:

    • 谢谢,我该怎么做?
    • 只需在您的收藏视图中使用setCollectionViewLayout:animated: 选择器。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-02
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2011-07-27
    • 2012-07-08
    • 1970-01-01
    相关资源
    最近更新 更多