問題[●●●]:什麼是UIKit Dynamics?

weixin_33670713發表於2016-05-20

Apps can now specify dynamic behaviors for UIView objects and for other objects that conform to the UIDynamicItem protocol. (Objects that conform to this protocol are called dynamic items.) Dynamic behaviors offer a way to improve the user experience of your app by incorporating real-world behavior and characteristics into your app’s user interface. UIKit dynamics supports the following types of behaviors:

  • A UIAttachmentBehavior object specifies a connection between two dynamic items or between an item and a point. When one item (or point) moves, the attached item also moves. The connection is not completely static, though. An attachment behavior has damping and oscillation properties that determine how the behavior changes over time.
  • A UICollisionBehavior object lets dynamic items participate in collisions with each other and with the behavior’s specified boundaries. The behavior also lets those items respond appropriately to collisions.
  • A UIGravityBehavior object specifies a gravity vector for its dynamic items. Dynamic items accelerate in the vector’s direction until they collide with other appropriately configured items or with a boundary.
  • A UIPushBehavior object specifies a continuous or instantaneous force vector for its dynamic items.
  • A UISnapBehavior object specifies a snap point for a dynamic item. The item snaps to the point with a configured effect. For example, a dynamic item can snap to the point as if it were attached to a spring.
    Dynamic behaviors become active when you add them to an animator object, which is an instance of the UIDynamicAnimator class. The animator provides the context in which dynamic behaviors execute. A given dynamic item can have multiple behaviors, but all of those behaviors must be animated by the same animator object.

For information about the behaviors you can apply, see UIKit Framework Reference.

擴充套件閱讀:
WWDC 2013 Session筆記 - UIKit Dynamics入門

相關文章