Dynamic animation 0720

##Dynamic animation

This is essentially animating using physics so we assign gravity and  collision boundaries and things like that to views, and then you just say go, and gravity starts pulling on it, and it hits the boundary and it bounces off and things like that. So it's a physics-based animation of views.

It's a little different approach to animation than the UIView-based. The UIView-based, your pretty much directly changing the things you want to change and then animating that change. Here you're just describing how things interact and then letting them go. However then want to go based on whatever restrictions and physics you put upon them.

How to do dynamic animation

Create a UIDynamicAnimator

Add UIDynamicBehaviors to it (gravity, collisions, etc.)

Add UIDynamicItems (usually UIViews) to the UIDynamicBehaviors (UIDynamicItem is a protocol which UIView happens to implement )

Things will instantly start animating. Reference view, the top level view, where all the animations is happening.

你可能感兴趣的:(Dynamic animation 0720)