Skip to content

Instantly share code, notes, and snippets.

View andresbrun's full-sized avatar

Andrés Brun andresbrun

View GitHub Profile
@andresbrun
andresbrun / UIPushBehaviour_continuous.swift
Created December 21, 2016 08:55
Shows how to apply a continuous push
let pushContinousBehaviour = UIPushBehavior(items: [targetView], mode: .continuous)
animator.addBehavior(pushContinousBehaviour)
// Using pushDirection
pushContinousBehaviour.pushDirection = CGVector(dx: 50, dy: 0)
// Using magnitude and angle
pushContinousBehaviour.magnitude = 50
pushContinousBehaviour.angle = 0
@andresbrun
andresbrun / FirstBehaviour.swift
Last active December 23, 2016 10:10
Shows how to create an animator, a behaviour and configure them
let animator = UIDynamicAnimator(referenceView: containerView)
let gravityBehaviour = UIGravityBehavior(items: [targetView])
gravityBehaviour.magnitude = 1.0 // gravity on earth
animator.addBehavior(gravityBehaviour)
@andresbrun
andresbrun / SettingPlayground.swift
Last active December 21, 2016 08:45
Create easily a view in Playground to play with
import UIKit
import PlaygroundSupport
let containerView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 320.0, height: 480.0))
// Play with containerView
let targetView = UIView(frame: CGRect(x: containerView.bounds.midX,
y: containerView.bounds.midY,
width: 50.0,
height: 50.0))