在执行旋转动画之前,我首先执行 UIImageView 的旋转:

// rotate to the left by 90 degrees
someView.transform = CGAffineTransformMakeRotation((-0.5)*M_PI);

然后调用 View 旋转 180 度......但它似乎是从原始位置开始旋转图像,就好像它最初没有旋转一样。
- (void)rotateIndicatorToAngle: (UIView *)view angle: (NSNumber *)angleInDegrees
{
    CALayer *layer = view.layer;
    CGFloat duration = 5.0;
    CGFloat radians = [self ConvertDegreesToRadians: [angleInDegrees floatValue]];
    CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: radians];
    rotationAnimation.duration = duration;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 1.0;
    rotationAnimation.removedOnCompletion = NO;
    rotationAnimation.fillMode = kCAFillModeForwards;
    rotationAnimation.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseOut];

[layer addAnimation: rotationAnimation forKey: @"rotationAnimation"];
}

是什么赋予了?

最佳答案



您是否尝试过使用 rotationAnimation.additive = YES; 而不是累积?

关于objective-c - CABasicAnimation 之前的 CGAffineTransformMakeRotation,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3969211/

10-13 03:01