ipad touch animation
Im having trouble animating a wheel using touch. Ive spent some time punching in different numbers values for duration, spin times and animation durations to get a smooth move using on thouchsMove, but every time a touch happens the wheel rotates and what seems to be happening is it jumps back to its original position. If any one can shed some light on this i would very much appreciate it.
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.fillMode = kCAFillModeForwards;
rotationAnimation.removedOnCompletion = NO;
rotationAnimation.delegate = self;
rotationAnimation.toValue = [NSNumber numberWithFloat: 2 * 1 * 45 ];
rotationAnimation.duration = 2;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 1;
rotationAnimation.timingFuncti开发者_JS百科on = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[animatedImage.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
for those interested code below is whats needed to get the desired effect
CGAffineTransform transforms = CGAffineTransformConcat(animatedImage.transform,CGAffineTransformMakeRotation(M_PI/2));
animatedImage.transform = transforms;
If you are having the same problem follow this example, its spot on. http://ericmcconkie.com/2010/03/trig-and-objective-c/
精彩评论