samedi 30 juillet 2016
Spin bottle with UIGestureRecognizer
I am using this code now to spin bottle on button tap:
@IBAction func spinButton(sender: AnyObject) {
let rotateView = CABasicAnimation()
let randonAngle = arc4random_uniform(360) + 720
rotateView.fromValue = 0
rotateView.toValue = Float(randonAngle) * Float(M_PI) / 180.0
rotateView.duration = 3
rotateView.delegate = self
rotateView.repeatCount = 0
rotateView.removedOnCompletion = false
rotateView.fillMode = kCAFillModeForwards
rotateView.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
bottleImageView.layer.addAnimation(rotateView, forKey: "transform.rotation.z")
}
But how can I rotate the button using gesture? So the harder/faster I move my finger, the faster the bottle will spin
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire