Tutorial by Examples

Lets draw a square in the middle of our view and make it fall to the bottom and stop at the bottom edge collising with the screen bottom boundary. @IBOutlet var animationView: UIView! var squareView:UIView! var collision: UICollisionBehavior! var animator: UIDynamicAnimator! var gravity: UIGr...
This example shows how to have a view track a pan gesture and depart in a physics-based manner. Swift class ViewController: UIViewController { // Adjust to change speed of view from flick let magnitudeMultiplier: CGFloat = 0.0008 lazy var dynamicAnimator: UIDynamicAnimator ...
This example shows how to achieve an effect similar to FaceTime were a view is attracted to point once it enters a particular region, in this case two regions a top and bottom. Swift class ViewController: UIViewController { lazy var dynamicAnimator: UIDynamicAnimator = { let ...
This example shows how to create a custom presentation transition that is driven by a composite UIDynamicBehavior. We can start by creating a presenting view controller that will present a modal. Swift class PresentingViewController: UIViewController { lazy var button: UIButton = { ...
This example shows how to make an interactive presentation transition with "real-world" physics similar to iOS's notifications screen. To start with, we need a presenting view controller that the shade will appear over. This view controller will also act as our UIViewControllerTransitio...
This example shows how to customize the UIDynamicItem protocol to map position changes of a view being dynamically animated to bounds changes to create a UIButton that expands and contracts in a elastic fashion. To start we need to create a new protocol that implements UIDynamicItem but that also...

Page 1 of 1