UICollectionView:选择时动画单元格大小更改 [英] UICollectionView: Animate cell size change on selection

查看:194
本文介绍了UICollectionView:选择时动画单元格大小更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是更改UICollectionViewCell的大小,并在选择单元格时为该更改设置动画。我已经设法通过在 collectionView:didSelectItemAtIndexPath:中标记一个单元格,然后在我的上面调用 reloadData 来实现非动画UICollectionView,显示不同大小的选定单元格。

What I want to do is change the size of an UICollectionViewCell, and to animate that change, when the cell is selected. I already managed to do that unanimated by marking a cell as selected in collectionView: didSelectItemAtIndexPath: and then calling reloadData on my UICollectionView, displaying the selected cell with a different size.

尽管如此,这一切都发生了,我不知道如何让动画的大小变化。有什么想法?

Nevertheless, this happens all at once, and I have no clue how to get that change in size animated. Any ideas?

我已经找到了 Animate uicollectionview细胞选择,但答案是对我不明确,我还没弄清楚它是否也可以帮助我。

I already found Animate uicollectionview cells on selection, but the answer was to unspecific for me and I didn't figure out yet if it could also help me in my case.

推荐答案

[UIView transitionWithView:collectionView 
                  duration:.5 
                   options:UIViewAnimationOptionTransitionCurlUp 
                animations:^{

    //any animatable attribute here.
    cell.frame = CGRectMake(3, 14, 100, 100);

} completion:^(BOOL finished) {

    //whatever you want to do upon completion

}];

didselectItemAtIndexPath 方法。

这篇关于UICollectionView:选择时动画单元格大小更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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