1
使用此代码我试图旋转图像。图像旋转但速度相同。 我试图旋转图像以平滑旋转,但我不能这样做。这里是我的代码:以平稳的速度旋转图像
(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"];
}
它的工作,但对于单个旋转不是总转 – jpd
第一次旋转后会发生什么?如果没有缓解功能,它会停止还是继续? – HashtagMarkus
它继续但没有效果 – jpd