如何将按钮向前移动?

时间:2015-04-25 23:01:54

标签: swift

我在故事板上放置了按钮并将它们放置在块落下的位置,但块阻挡/覆盖按钮。如何将按钮向前移动?

import UIKit

class interestViewController: UIViewController {

var squareView: UIView!
var gravity: UIGravityBehavior!
var animator: UIDynamicAnimator!
var collision: UICollisionBehavior!

override func viewDidLoad() {
    super.viewDidLoad()

    squareView = UIView(frame: CGRectMake(100, 100, 100, 100))

    view.addSubview(squareView)
    animator = UIDynamicAnimator(referenceView: view)

    squareView.backgroundColor = UIColor.blackColor()
    gravity = UIGravityBehavior(items: [squareView])
    animator.addBehavior(gravity)
    collision = UICollisionBehavior(items: [squareView])
    collision.translatesReferenceBoundsIntoBoundary = true
    animator.addBehavior(collision)

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

0 个答案:

没有答案