UIKit Dynamics is a feature introduced in iOS 7 that enables dynamic behaviors, which offers a way to enhance the user experience by incorporating real-world behaviors and characteristics, such as gravity, into your animations.
UIKit Dynamics is "a composable, reusable, declarative, real-world inspired animation, and interaction system" (as described in WWDC 2013 video, Getting Started with UIKit Dynamics).
Any object that conforms to the UIDynamicItem
protocol, such as UIView
objects, can be associated with "behaviors" that can be added to a dynamic animator, a UIDynamicAnimator
. These behaviors include forces, elasticity, gravity, collisions, etc.
The types of behavior objects which can be added to the UIDynamicAnimator
object include UIAttachmentBehavior
, UICollisionBehavior
, UIDynamicItemBehavior
, UIGravityBehavior
, UIPushBehavior
, and UISnapBehavior
. You can also combine these behaviors together or create your own custom dynamic behaviors.
UIKit Dynamics is not designed to replace Core Animation or UIView
animations, but is designed to offer another mechanism to easily create more interactive and dynamic animations with less code. Likewise, UIKit Dynamics is not intended to replace SpriteKit, which might be better suited for many games.
Resources:
- UIDynamicAnimator Class Reference
- WWDC 2013 video Getting Started with UIKit Dynamics
- WWDC 2013 video Advanced Techniques with UIKit Dynamics
- UIKit Framework Reference