A behavior that applies a continuous or instantaneous force to one or more dynamic items, causing those items to change position accordingly.
- iOS 7.0+
- tvOS 9.0+
A dynamic item is any iOS or custom object that conforms to the
UIDynamic protocol. The
UICollection 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
The default magnitude of a push behavior’s force vector is
nil, equivalent to no force. A continuous force vector with a magnitude of
1, applied to a 100 point x 100 point view whose density value is
1, results in view acceleration of 100 points / second² in the direction of the vector; this value is also known as the UIKit Newton.
You express a push behavior’s force vector in terms of magnitude (
magnitude) and radian angle (
angle). Instead of using radian angle, you can equivalently express direction using x and y components by using the
push property. Whichever approach you use, the alternate, equivalent values update automatically.
For each dynamic item that you associate with a push, the force is applied at the item center or at a specified offset from the center in item-relative coordinates.
To use a push behavior with a dynamic item, perform these two steps:
Enable the behavior by adding it to an animator using the
After enabling a push behavior, you can activate it and deactivate it using the
The coordinate system that pertains to a push 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
You can include a push behavior in a custom, composite behavior by starting with a
UIDynamic object and adding a push behavior with the
add method. If you want to influence a push behavior at each step of a dynamic animation, implement the inherited