uikit dynamics
DESCRIPTION
A basic overview of UIKit Dynamics. Demo here: https://github.com/rob-brown/DemosTRANSCRIPT
![Page 1: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/1.jpg)
UIKit DynamicsRobert Brown Twitter: @robby_brown ADN: @robert_brown
![Page 2: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/2.jpg)
What is UIKit Dynamics?
A composable, reusable, declarative, real-world inspired animation and interaction system.
![Page 3: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/3.jpg)
What is UIKit Dynamics?Based on real-world interactions
Gravity
Collisions
Attachments
Snap
Forces
Weight
![Page 4: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/4.jpg)
Limitations
It is possible to create behaviors that can’t be satisfied
Not completely accurate physics
Does not replace Core Animation, UIView animations, or motion effects
Only supports 2D transforms
![Page 5: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/5.jpg)
UIGravityBehavior
Gravity is a simple vector
Default is (0, 1) meaning straight down
Default constant is 1000 px/sec2
![Page 6: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/6.jpg)
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
![Page 7: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/7.jpg)
UIAttachmentBehavior
Acts like a rope, string, or spring
Damping is customizable
Has a length and two anchor points
Attachments are invisible
![Page 8: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/8.jpg)
UISnapBehavior
Locks position and angle
Can use damping
![Page 9: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/9.jpg)
UIPushBehavior
Simple force vector
1 UIKit Newton accelerates a (100,100) view by 100 px/sec2
![Page 10: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/10.jpg)
UIDynamicItemBehaviorfriction
resistance
angularResistance
elasticity
density
allowsRotation
![Page 11: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/11.jpg)
Composing Behaviors
Effect Combination
Bounce Gravity + collision
Drag and snap Attachment then snap
Lock screen Gravity + Collision + Attachment + Push
Magnet Multiple push
![Page 12: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/12.jpg)
Demo
![Page 13: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/13.jpg)
Questions?
![Page 14: UIKit Dynamics](https://reader030.vdocuments.mx/reader030/viewer/2022020122/54b768504a795971038b45b3/html5/thumbnails/14.jpg)
Want to Learn More?
WWDC 2013 Session 206
WWDC 2013 Session 221
UIKit Dynamics Catalog Sample