Skip to content

Instantly share code, notes, and snippets.

@andresbrun
Last active December 23, 2016 09:00
Show Gist options
  • Save andresbrun/db8b70f9ac0894a8d7227b866c0c2be8 to your computer and use it in GitHub Desktop.
Save andresbrun/db8b70f9ac0894a8d7227b866c0c2be8 to your computer and use it in GitHub Desktop.
Shows how to add a collision behaviour
let collisionBehaviour = UICollisionBehavior(items: [targetView])
animator.addBehavior(collisionBehaviour)
// Collision with bounds of superview
collisionBehaviour.setTranslatesReferenceBoundsIntoBoundary(with: .zero)
// Collision with custom boundaries
collisionBehaviour.addBoundary(withIdentifier: "barrier" as NSCopying,
for: UIBezierPath(ovalIn: containerView.bounds))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment