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

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

问题描述

我想要做的是更改 UICollectionViewCell 的大小,并在选择单元格时为该更改设置动画.我已经设法通过在 collectionView: didSelectItemAtIndexPath: 中将一个单元格标记为选中,然后在我的 UICollectionView 上调用 reloadData 以不同大小显示选定单元格来做到这一点./p>

尽管如此,这一切都是同时发生的,我不知道如何使大小的变化动画化.有什么想法吗?

我已经找到 动画 uicollectionview 单元格的选择,但答案是不确定的对我来说,我还不知道它是否也可以帮助我.

解决方案

[UIView transitionWithView:collectionView持续时间:.5选项:UIViewAnimationOptionTransitionCurlUp动画:^{//这里的任何动画属性.cell.frame = CGRectMake(3, 14, 100, 100);}完成:^(布尔完成){//完成后你想做什么}];

在你的 didselectItemAtIndexPath 方法中玩一些类似的东西.

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?

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

}];

Play around with something along those lines inside your didselectItemAtIndexPath method.

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

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