際際滷

際際滷Share a Scribd company logo
UIKit Dynamics
Robert Brown
Twitter: @robby_brown
ADN: @robert_brown
What is UIKit Dynamics?

A composable, reusable, declarative, real-world
inspired animation and interaction system.
What is UIKit Dynamics?
Based on real-world interactions
Gravity
Collisions
Attachments
Snap
Forces
Weight
Limitations
It is possible to create behaviors that cant be satis鍖ed
Not completely accurate physics
Does not replace Core Animation, UIView animations,
or motion effects
Only supports 2D transforms
UIGravityBehavior

Gravity is a simple vector
Default is (0, 1) meaning straight down
Default constant is 1000 px/sec2
UICollisionBehavior
Views can collide with boundaries and other views
Views can collide conditionally with other views
Callbacks for when collisions begin and end
(UICollisionBehaviorDelegate)
Collisions have a CPU cost
UIAttachmentBehavior
Acts like a rope, string, or spring
Damping is customizable
Has a length and two anchor points
Attachments are invisible
UISnapBehavior

Locks position and angle
Can use damping
UIPushBehavior

Simple force vector
1 UIKit Newton accelerates a (100,100) view by 100
px/sec2
UIDynamicItemBehavior
friction
resistance
angularResistance
elasticity
density
allowsRotation
Composing Behaviors
Effect

Combination

Bounce

Gravity + collision

Drag and snap

Attachment then snap

Lock screen

Gravity + Collision +
Attachment + Push

Magnet

Multiple push
Demo
Questions?
Want to Learn More?

WWDC 2013 Session 206
WWDC 2013 Session 221
UIKit Dynamics Catalog Sample

More Related Content

UIKit Dynamics