我有一个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);
}
}
现在我想将动画应用于单元格的扩展,在哪里编写此代码?
如果您希望对更改进行动画处理,请将它们放入调用中以执行批处理更新:完成: