Question

I'm trying to make an iPhone/iPad app, and I am currently trying to have an image spin slowly 360 degrees. But when I increase the animation duration, the picture rotates 1/4 of the way and then resets back to the beginning of the animation.

Can anyone tell me what is wrong with this?

What I have so far:

CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
[fullRotation setFromValue:[NSNumber numberWithFloat:0]];
[fullRotation setToValue:[NSNumber numberWithFloat:((2*M_PI))]];
fullRotation.speed = .5f;
fullRotation.duration = 5.5;
fullRotation.repeatCount = 1;

fullRotation.repeatCount = HUGE_VALF;

[[cosmic layer] addAnimation:fullRotation forKey:@"transform.rotation"];
Was it helpful?

Solution

Just delete this one line from your code:

fullRotation.speed = .5f;

and then adjust duration you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top