How can we Move an Image 360 Degree from the starting point to the ending point? Moving Image 360 Degree?
Asked
Active
Viewed 1,128 times
0
-
3not to sound rude , but do you mean 360 degree's rotation ? Wouldnt that just the image back in the same orientation ? or do you mean translation ? – Andrew Keith Oct 06 '09 at 05:52
-
As mahboudz points out, your question is very similar to this one: http://stackoverflow.com/questions/542739/can-i-use-cgaffinetransformmakerotation-to-rotate-a-view-more-than-360-degrees – Brad Larson Oct 06 '09 at 12:32
3 Answers
1
You can rotate a view, by some number of radians, regardless of whether it is less than a full rotation or many multiples of a full rotation, without having to split the rotation into pieces. As an example, the following code will spin a view, once per second, for a specified number of seconds. You can easily modify it to spin a view by a certain number of rotations, or by some number of radians.
- (void) runSpinAnimationWithDuration:(CGFloat) duration;
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 1.0;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[myView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}

mahboudz
- 39,196
- 16
- 97
- 124
1
A 360 degree rotation in any axis leaves the view unchanged. So don't touch the image, and you're good to go!

Jim Lewis
- 43,505
- 7
- 82
- 96
0
You could use an animation function (CAValueFunction) for this too:
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
rotationAnimation.duration = duration;
rotationAnimation.fromValue = [NSNumber numberWithFloat:0.0];
rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI * 2.0];
rotationAnimation.valueFunction = [CAValueFunction functionWithName:kCAValueFunctionRotateZ];
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[myView.layer addAnimation:rotationAnimation forKey:nil];

joplaete
- 113
- 1
- 9