【问题标题】:CAAnimationGroup with CAKeyframeAnimation and CABasicAnimationCAAnimationGroup 与 CAKeyframeAnimation 和 CABasicAnimation
【发布时间】:2013-07-31 23:06:14
【问题描述】:

我正在尝试沿曲线路径为视图设置动画并同时将其缩小:

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    pathAnimation.calculationMode = kCAAnimationPaced;
    pathAnimation.fillMode = kCAFillModeForwards;
    pathAnimation.removedOnCompletion = NO;
    //Setting Endpoint of the animation
    CGPoint endPoint = endCenter;
    CGMutablePathRef curvedPath = CGPathCreateMutable();
    CGPathMoveToPoint(curvedPath, NULL, viewOrigin.x, viewOrigin.y);
    CGPathAddCurveToPoint(curvedPath, NULL, viewOrigin.x+200, viewOrigin.y-150, endPoint.x+100, endPoint.y+10, endPoint.x, endPoint.y);
    pathAnimation.path = curvedPath;
    CGPathRelease(curvedPath);

    // Set up scaling
    CABasicAnimation *resizeAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    resizeAnimation.toValue = [NSNumber numberWithDouble:0.4];
    resizeAnimation.fillMode = kCAFillModeForwards;
    resizeAnimation.removedOnCompletion = NO;

    CAAnimationGroup *group = [CAAnimationGroup animation];
    group.fillMode = kCAFillModeForwards;
    group.removedOnCompletion = YES;
[group setAnimations:[NSArray arrayWithObjects: pathAnimation, resizeAnimation, nil]];
    group.duration = 3.7f;
    group.delegate = self;
    [group setValue:self.myView forKey:@"imageViewBeingAnimated"];

self.myView.center = endCenter;
self.myView.transform = self.myViewTransform;
[self.myView.layer addAnimation:group forKey:@"savingAnimation"];

问题在于,视图不是在移动时逐渐缩小,而是立即缩小,然后沿着路径移动。当它明显移动时,我需要按比例缩小。

【问题讨论】:

    标签: ios uiview cabasicanimation caanimation cakeyframeanimation


    【解决方案1】:

    这样做解决了:

    resizeAnimation.fromValue = [NSNumber numberWithDouble:1.0];
    

    我不明白为什么我必须这样做。似乎应该从当前转换的默认 fromValue 开始。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多