Search code examples
iosswiftuicollectionviewcore-animationuicollectionviewcell

UICollectionView clips cell during bounce animation


I use a rudimentary bounce animation in several places in my app. When a selection is made in one of the collection views, I bounce the selected item before acting on it. When I apply the bounce animation to the selected cell, the cell is clipped to the parent view frame. However, this clipping behavior doesn't occur with other child views.

In the video below, I created two examples of the bounce animation.

Video of bounce issue

The centered example is a child UIView (red) that is a child of the containing UIView (light gray). I can tap and bounce the child UIView (red) without it clipping to the parent view (gray).

The example at the bottom is a UICollectionView that demonstrates the clipping behavior of the UICollectionViewCell when it is selected (turns red).

The example Swift iPad app source code can be found here:

https://github.com/psparago/collection-view-bounce-test.git

My question is, is it possible to get the cell to bounce above the frame of the collection view?


Solution

  • Just off the top of my head, have you made sure that for the parent uicollectionviewcell had “Clip subviews” turned off in the attributes inspector?

    https://i.sstatic.net/LXa2Y.png