UICollectionView:选择时动画单元格大小变化 [英] UICollectionView: Animate cell size change on selection
问题描述
我想要做的是更改 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屋!