2

I'm using Facebook pop framework to perform some cool animations. I'm shaking a button in this way :

let rotation = POPSpringAnimation.init(propertyNamed: kPOPLayerRotation)
rotation.springBounciness = 30
rotation.springSpeed = 20
rotation.velocity = 30.0
rotation.repeatForever = true

button.layer.pop_addAnimation(rotation, forKey: "rotation")

Despite of the repeatForever set to true the animation doesn't repeat. I noticed that if we have the toValue property set, the animation repeats. Am I doing something wrong?

Andrea Mario Lufino
  • 7,921
  • 12
  • 47
  • 78

2 Answers2

2

I solved this issue adding the following:

rotation.fromValue = 0.0

Angels
  • 21
  • 3
0

You can do it with POPBasicAnimation. If you're rotating forever, you may not need the spring animation.

Looking at your code, you don't have a rotation.toValue You need to tell the animation how far to rotate. Try this:

func configureBtnRotation(btn: UIButton) {
  let rotation = POPBasicAnimation(propertyNamed: kPOPLayerRotation)
  rotation.toValue = 90.0
  rotation.duration = 100.0 //this sets the speed of rotation
  rotation.repeatForever = true
  button.layer.pop_addAnimation(rotation, forKey: "rotation")
}

Hope this helps.

D. Greg
  • 991
  • 1
  • 9
  • 21