0

I have an UIImageView which I have to give a rotation animation effect (starts rotating when the view appears and rotates constantly until that view disappears). I found this simple answer in another question: UIView Infinite 360 degree rotation animation?

But my question is how can i set the duration to the time until the view disappears. And also,what should I set the value of repeat count in my scenario.

Community
  • 1
  • 1
Ashwani R
  • 47
  • 2
  • 6

1 Answers1

1

What are you using to make the view disappear? If by disappear you mean fade the alpha to 0, you can just time your rotation animation to match up with an animation that fades the alpha. For example, if you have a rotation that lasts .25 seconds, and you want it to fade out after 1 second, have it rotate 4 times.

If you mean you're keeping the image view spinning until the user does something to make it go away, you can set the repeat count to infinite and just remove the animation from imageview once it's gone using the tag that you gave it when you added the animation:

[yourLayer addAnimation:yourAnimation forKey:@"spinning"]; when you add it

[yourLayer removeAnimationForKey:@"spinning"]; for once the imageview has disappeared

Chris C
  • 3,221
  • 1
  • 27
  • 31