Commit 06df484e authored by toby's avatar toby

add barrier

parent 98ce5cac
......@@ -30,16 +30,23 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let barrier = UIView(frame: CGRect(x: 0, y: 300, width: 130, height: 20))
barrier.backgroundColor = UIColor.redColor()
view.addSubview(barrier)
gravity = UIGravityBehavior()
gravity.angle = degreesToRadians(90)
gravity.magnitude = CGFloat(0.1)
collision = UICollisionBehavior()
collision.translatesReferenceBoundsIntoBoundary = true
collision.addBoundaryWithIdentifier("barrier", forPath: UIBezierPath(rect: barrier.frame))
animator = UIDynamicAnimator(referenceView: view)
animator.addBehavior(gravity)
animator.addBehavior(collision)
}
override func didReceiveMemoryWarning() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment