UISnapBehavior
A spring-like behavior whose initial motion is damped over time so that the object settles at a specific point.
Declaration
@MainActor class UISnapBehaviorOverview
A dynamic item is any iOS or custom object that conforms to the UIDynamicItem protocol. The UIView and UICollectionViewLayoutAttributes classes implement this protocol starting in iOS 7.0. You can use a custom object as a dynamic item for such purposes as reacting to rotation or position changes computed by a dynamic animator—an instance of the UIDynamicAnimator class.
To use a snap behavior with a dynamic item, perform these two steps:
Initialize a new snap behavior with the item using the init(item:snapTo:) method
Enable the behavior by adding it to an animator using the addBehavior(_:) method
The coordinate system that pertains to a snap behavior, and the types of dynamic items you can use with the behavior, depend on how you initialized the associated animator. For details, read the Overview of UIDynamicAnimator.
You can include a snap behavior in a custom, composite behavior by starting with a UIDynamicBehavior object and adding a snap behavior with the addChildBehavior(_:) method. If you want to influence a snap behavior at each step of a dynamic animation, implement the inherited action method.