I want an rotation on my Icon, so it will show its tendency from the month before.
If I go a month before, the Icon jumps back to its normal state and goes up or down.
But I want a smooth Animation!
I tried to built more than one CABasicAnimation instances and it did the trick, but this isn't good!
here is my method:
-(void)rotateTrafficAnimation:(UIImageView *)imageView :(float)rotation {
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: rotation]; // M_PI/2.0
//NSLog(@"PIHALBE: %f", M_PI/2.0);
rotationAnimation.duration = 1;
rotationAnimation.cumulative = YES;
rotationAnimation.removedOnCompletion = FALSE;
rotationAnimation.autoreverses = NO;
rotationAnimation.fillMode = kCAFillModeForwards;
rotation开发者_如何转开发Animation.repeatCount = 0;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[imageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
//[rotationAnimation autorelease];
}
So how can I do it whiteout many of CABasicAnimation instances?
So what Maverick1st told me in the comments worked out for me, so thanks a lot.
rotation.fromValue
Did the trick for me.
精彩评论