使用此代码我正在尝试旋转图像。图像旋转但速度相同。我正在尝试通过平滑旋转来旋转图像,但我不能这样做。这是我的代码:
(void)spinLayer:(CALayer *)inLayer duration:(CFTimeInterval)inDuration
direction:(int)direction repeat:(int)repeat
{
repeatcount = repeat+repeatcount;
timer = [NSTimer scheduledTimerWithTimeInterval: inDuration target: self selector:@selector(setCountLableValue) userInfo: nil repeats: YES];
CABasicAnimation* rotationAnimation;
rotationAnimation =
[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.fromValue = [NSNumber numberWithFloat: M_PI *2.0 * direction];
rotationAnimation.repeatCount = repeat;
NSLog(@"Repeat count %d",repeat);
rotationAnimation.duration = inDuration;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[inLayer addAnimation:rotationAnimation forKey:@"rotation"];
}