UICollectionViewCell scale cell size while scrolling

后端 未结 1 605
一个人的身影
一个人的身影 2021-01-02 19:20

I\'m trying to create a UICollectionView where the UICollectionViewCell is getting scaled down when \"leaving\" the visible area at the top or bottom. And getting scaled up

相关标签:
1条回答
  • 2021-01-02 19:51

    Not a complete solution, but a few remarks/pointers:

    1. You should not mess with the collection view cells directly in this way, but rather have a custom UICollectionViewLayout subclass that modifies the UICollectionViewLayoutAttributes to include the desired transform and invalidating the layout whenever necessary.

    2. Doing if pos.origin.y == 50 is definitely not a good idea, because the scrolling might not pass by all values (that is, it might jump from 45 to 53). So, use >= and include some other way if you want to ensure that your animation is only executed once at the "boundary" (for example, store the last position or a flag).

    0 讨论(0)
提交回复
热议问题