Animate uicollectionview cells on selection

后端 未结 2 717
无人及你
无人及你 2021-01-14 17:49

I have created a customlayout and set my cells position attribute in layoutAttributesForItemAtIndexPath like this

attributes.center = CGPointMake         


        
2条回答
  •  猫巷女王i
    2021-01-14 18:30

    I'm animating the attributes by using didSelectItemAtIndexPath in my UICollectionViewDelegate:

    - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
    {
        [_collectionView.collectionViewLayout invalidateLayout];
        UICollectionViewLayoutAttributes *newAttributes = [_collectionView layoutAttributesForItemAtIndexPath:indexPath];
    
        //use new attributes for animation
    }
    

提交回复
热议问题