【发布时间】:2015-07-31 01:54:55
【问题描述】:
所以我试图将重力添加到 4 个 UIButtons 但它们没有下降,我将此代码添加到确实加载的视图中,我不知道为什么这不能正常工作。 这是代码:
//initialize the animator
var animator = UIDynamicAnimator(referenceView: self.view)
//add gravity
let gravity = UIGravityBehavior(items: [redButton!, greenButton!, blueButton!, cameraButton!])
let direction = CGVectorMake(0.0, 1.0)
gravity.gravityDirection = direction
animator.addBehavior(gravity)
我的按钮是 redButton、greenButton、blueButton 和 cameraButton,我还应用了秋天的方向,但是当我运行应用程序时,它们只是静态的。那么是否可以向 UIButtons 添加重力?
【问题讨论】: