2

曲線のパスに沿ってビューをアニメーション化し、同時に縮小しようとしています:

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"];

問題は、ビューが移動するにつれて徐々に縮小するのではなく、すぐに縮小されてからパスに沿って移動することです。明らかに動くので縮小する必要があります。

4

1 に答える 1

1

これを行うことで解決しました:

resizeAnimation.fromValue = [NSNumber numberWithDouble:1.0];

なぜこれをしなければならないのかわかりません。現在の変換のデフォルトの fromValue から開始する必要があるようです。

于 2013-07-31T23:46:57.810 に答える