Ios 像滴答作响的时钟一样旋转一层,不是一个平滑的圆圈

Ios 像滴答作响的时钟一样旋转一层,不是一个平滑的圆圈,ios,core-animation,Ios,Core Animation,我可以将图像连续旋转一定的角度,但我想将图像旋转一点点,暂停,再多一些,暂停,等等 以下代码持续执行此操作: // rotate CGFloat finalValue = 360 / 14.f; CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; [rotationAnimation setFromValue:[self degreesToNumb

我可以将图像连续旋转一定的角度,但我想将图像旋转一点点,暂停,再多一些,暂停,等等

以下代码持续执行此操作:

// rotate
CGFloat finalValue = 360 / 14.f;
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
[rotationAnimation setFromValue:[self degreesToNumber:0]];
[rotationAnimation setToValue:[self degreesToNumber:finalValue]];
[rotationAnimation setDuration:5.0];
[rotationAnimation setRemovedOnCompletion:NO];
[rotationAnimation setFillMode:kCAFillModeForwards];
[self.secondHandImageView.layer addAnimation:rotationAnimation forKey:@"rotate"];
有没有一种方法可以根据我需要的角度变化数量将其包装在for循环中,并设置特定动画的持续时间和延迟?我试过的东西都不管用。以下是我目前正在尝试的内容:

// rotate in ticks, so
NSTimeInterval delay = 0;
CGFloat currentAngle = 0;
CGFloat finalAngle = 360 / 14.f;

// angle difference
CGFloat numberOfTicks = 25.f;
CGFloat angleDelta = finalAngle / numberOfTicks;

for (NSUInteger tick = 0; tick < numberOfTicks; tick++) {
    [UIView animateWithDuration:0.1 delay:delay options:UIViewAnimationOptionCurveLinear animations:^{
        self.secondHandImageView.layer.transform = CATransform3DMakeRotation(0, 0, angleDelta, 1.0);
    } completion:nil];

    // update delay
    delay += .2; // 200 milliseconds, 5 tickets every second
    currentAngle += angleDelta;
}
//以刻度旋转,所以
NSTIME间隔延迟=0;
CGFloat currentAngle=0;
CGFloat finalAngle=360/14.f;
//角度差
CGFloat numberOfTicks=25.f;
CGFloat ANGLOTE DELTA=最终语言/刻度数;
对于(整数勾号=0;勾号
您编写的代码是正确的-除了不能在UIView动画块内设置层动画。相反,您可以设置视图的动画。将(3D)图层变换替换为(2D)视图变换:

 self.secondHandImageView.transform = 
      CGAffineTransformRotate(self.tickView.transform,angleDelta);