iosswiftxcodeanimationuikit-dynamics

Animate UICollectionView with UIDynamics Swift


In the Apple's own documentation, it states the steps on how to build that behavior, but I don't quite understand, can somebody tell me how to do that in code.

To animate collection views, create an animator with the init(collection​View​Layout:​) method. The resulting animator employs a collection view layout (an object of the UICollection​View​Layout class) for its coordinate system. The dynamic items in this sort of animator must be UICollection​View​Layout​Attributes objects that are part of the layout. You can define a boundary, for items participating in a collision behavior, relative to the bounds of the collection view layout. See the set​Translates​Reference​Bounds​Into​Boundary(with:​) method. A collection view animator automatically calls the invalidate​Layout() method as needed, and automatically pauses and resumes animation, as appropriate, when you change a collection view’s layout.


Solution

  • This is a little out-of-date, but looks like an interesting introduction to it: https://www.objc.io/issues/5-ios7/collection-views-and-uidynamics/