创建一个“任务兔”——就像在iOS中一样

创建一个“任务兔”——就像在iOS中一样,ios,rotation,Ios,Rotation,任何专家请帮助我,我已经挣扎了几天。我正在实现我在互联网上找到的旋转轮控制,但我需要让它在用户在屏幕上滑动时旋转,它应该旋转得很快,然后减速,并像应用程序任务兔子那样停止 我成功地创建了轮子并使其旋转,但它带来了另一个问题,让我向您展示我的代码 - (void)playRotationAnimation:(NSNumber*) _initialVelocity{ double currentVelocity = ([self doubleAbs:[_initialVelocity dou

任何专家请帮助我,我已经挣扎了几天。我正在实现我在互联网上找到的旋转轮控制,但我需要让它在用户在屏幕上滑动时旋转,它应该旋转得很快,然后减速,并像应用程序任务兔子那样停止

我成功地创建了轮子并使其旋转,但它带来了另一个问题,让我向您展示我的代码

- (void)playRotationAnimation:(NSNumber*) _initialVelocity{
    double currentVelocity = ([self doubleAbs:[_initialVelocity doubleValue]])/10;
    while (currentVelocity > 0.1 && self.isRotatingWheel) {
        currentVelocity -= currentVelocity * 0.1;
        double netRotation = currentVelocity;
        if([_initialVelocity doubleValue] < 0) netRotation *= -1;
        NSNumber *_rotation = [NSNumber numberWithFloat:((netRotation * M_PI) / 180)];
        [self performSelectorOnMainThread:@selector(rotateWheelView:) withObject:_rotation waitUntilDone:YES];
        [NSThread sleepForTimeInterval:0.07];
    }
    [self performSelectorOnMainThread:@selector(animationStopped) withObject:nil waitUntilDone:YES];
}
好的,这里是想法:播放旋转动画将使滚轮保持滚动,直到当前速度达到极限,滚轮将根据速度角度滚动

问题是,当我刷卡时,首先,它旋转得很好,然后突然,它向后滚动。例如,它顺时针旋转一段时间,突然改变方向,逆时针旋转

我希望有人能帮我解决这个案子:

- (void)rotateWheelView:(NSNumber *)_rotation {
    double rotation = [_rotation doubleValue];
    container.transform = CGAffineTransformRotate(container.transform, rotation);
    NSLog(@"%g", rotation);
}