2

我试图沿着弯曲的路径动画视图和规模下来同时:CAAnimationGroup与CAKeyframeAnimation和CABasicAnimation

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

的问题是,缩小逐渐因为它的动作,而不是图,它会立即缩小,然后沿着路径移动。当它明显移动时,我需要缩小比例。

回答

1

解决做这个:

resizeAnimation.fromValue = [NSNumber numberWithDouble:1.0]; 

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