I have a UIViewControler with 4 layers.
- Face Plate of a Watch/Clock
- Second Hand
- Minute Hand
- Hour Hand
I've gotten each hand to start moving onload at the correct time (by defining angles on a circle based on the time the app-loads).
How do I correctly define the motion and duration of motion (should be ad infinitum) using the CABasicAnimation
accessor methods?
For instance, I've set my secondHandMotion (which is an instantiated CABasicAnimation object) to being at an angle on the clock frame that corresponds to current time:
CABasicAnimation *secondHandMotion = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
secondHandMotion.fromValue = [NSNumber numberWithFloat:sAlpha];
secondHandMotion.toValue = [NSNumber numberWithFloat:(2*M_PI)];
[secondHand addAnimation:secondHandMotion forKey:@"transform"];
where sAlpha
is the angle as a function of time.
The secondHandMotion.toValue
statement is wrong, I know that. How do I tell it to keep moving, and at the correct interval, 1-second ticks?
Thanks!
secondHandMotion.duration = 60.0
, I get that it the secondHand makes a full loop in 60 seconds, but then it stops, since I don't know how to have it keep going (forever) after a 2-pi loop. – ArtSabintsev