Resize and select the UicollectionViewCell ribbon with animation

I want to enlarge all the cells when I tapped on any cell and scroll the UICollectionView into this cell with animation.

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    fullScreen = !fullScreen;
    [self.photoCollectionView performBatchUpdates:^{
        [self.photoCollectionView.collectionViewLayout invalidateLayout];
    } 
    completion:^(BOOL finished){
         [self.photoCollectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO];
     }];
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 
{
   if (fullScreen)
      return CGSizeMake(collectionView.frame.size.width, collectionView.frame.size.height);
   else
      return CGSizeMake(80, 80);
}

The problem is that I first see the first element and then scroll to the ribbon. And I want to animate an element resize cell.

+4
source share

All Articles