UICollectionViewFlowLayout binds cell to place using UIKitDynamics

I subclassed UICollectionViewFlowLayout

and I have prepareForLayout

added nesting behavior between each of my cells, without any changes to it UIAttachmentBehavior

, so this is just a rigid application. My plan was that then when the first cell was clicked to add UISnapBehavior

to the first cell and snap it to the top and just need all the other cells to follow as they are all linked to each other, however once i try to do this. I get a famous message UIKit Dynamics

in the console when it doesn't know what to do with both behaviors.

If I first remove the nesting behavior between the first and second cells and then add the snapping behavior, the first cells snap to the top as expected, but of course none of the other cells follow, since there is no more nesting, I feel like it should be possible, but I might just think about it the wrong way, how could I solve this with UIKit Dynamics

?. I know I could probably solve this simply by moving the offset of the collectionView content to the UIView animation with spring effect, but I want more control over the animation.

The behavior I want is very similar to the Google Now app in the App Store where you click the first card and it snaps to the top while all other cells follow. I realize this could have moved the offset of the content, but I believe this is what is best handled with UIKit Dynamics

, however I am at a loss as to how to achieve this behavior.

I haven't worked with stream UIKitDynamics

and collection layout before , so I might overlook something obvious here.

+3


source to share





All Articles