I have subclassed UICollectionViewFlowLayout
and I have in prepareForLayout
added a attachment behavior between each of my cells, without any modification to the UIAttachmentBehavior
so that it is just a rigid attachment. My plan was to then when the first cell is tapped to add a UISnapBehavior
to the first cell and snap it to the top, and simply have all the others cell follow this one since they are all linked together, however as soon as I try to do this I get the known UIKit Dynamics
message in the console when it doesn't know what to do with both behaviors.
If I first remove the attachment behavior between the first and second cell, and then add the snap behavior, the first cells snaps to the top as expected, but of course none of the others cell follow since there is no longer an attachment. It seems to me like this should be possible, but I might just be thinking about this the wrong way, how could I solve this with UIKit Dynamics
?. I know that I could probably solve this by simply moving the content offset of the collectionView a UIView animation with spring effect, but I want to have more control over the animation.
The behavior I want, is very similar to the Google Now app in the App Store, where you tap the first card and it snaps to the top while all the other cells follow. I realize this might have been moving the content offset, but I feel this is something that would be better handled by UIKit Dynamics
, however I am at lost as to how to achieve this behavior.
I haven't worked with UIKitDynamics
and collection view flow layout before, so I might be missing something obvious here.