I'm using UIKit dynamics to create a falling object and i was wondering if i could actually slow the gravity to make the ball fall slower on command. For example, the object will be falling, I press a button, then the ball falls slower. How would i go about doing this? Here is my code (P.S. I added the squareView above this but I didn't include it because it's irrelevant to the question)
var squareView: UIImageView!
var gravity: UIGravityBehavior!
var animator: UIDynamicAnimator!
var collision: UICollisionBehavior!
func viewDidLoad() {
super.viewDidLoad()
animator = UIDynamicAnimator(referenceView: view)
gravity = UIGravityBehavior(items: [squareView])
gravity.gravityDirection = CGVector(dx: 0.0, dy: 1.1)
animator.addBehavior(gravity)
}
I tried writing gravity.gravityDirection = CGVector(dx: 0.0, dy: 0.5) but it just flung the object across the screen frantically so I don't know what to do here.