【问题标题】:How to animate UICollectionViewCell expansion?如何动画 UICollectionViewCell 扩展?
【发布时间】:2017-11-14 16:55:06
【问题描述】:

我有一个 UICollectionView。当用户点击一个单元格时,我必须扩大单元格的大小。我就是这样子的,

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    [collectionView performBatchUpdates:^{
        isExpandedMode = true;
        expandedPosition = indexPath.row;
        [self.collectionView reloadItemsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil]];
    } completion:^(BOOL finished) {

    }];
}

现在我在这里更新单元格大小,

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    if(isExpandedMode && expandedPosition == indexPath.row){
        CGFloat screenWidth = 568.0;
        CGFloat screenHeight = 293.0;
        return CGSizeMake(screenWidth, screenHeight);
    }
    else{
        CGFloat screenWidth = 172.0;
        CGFloat screenHeight = 293.0;
        return CGSizeMake(screenWidth, screenHeight);
    }
}

现在我想对单元格的展开应用动画,这段代码在哪里写?

【问题讨论】:

    标签: ios objective-c uicollectionview uicollectionviewcell uianimation


    【解决方案1】:

    如果您希望更改动画,请将它们放在对 performBatchUpdates:completion: 的调用中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多