0
我有一個明確的動畫,我想設置最終值,以便對象停留在終點。但我怎麼能在延遲動畫上實現這一點:這裏是代碼:如何設置顯式CA動畫延遲的最終值
CAKeyframeAnimation *moveAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
moveAnimation.duration = 0.3;
moveAnimation.cumulative = YES;
moveAnimation.repeatCount = 1;
// Bounce
[moveAnimation setValues:[NSArray arrayWithObjects:
[NSValue valueWithCGPoint:[self getCoordinatePointForAnimationWithRadius:0 withIndex:i]],
[NSValue valueWithCGPoint:[self getCoordinatePointForAnimationWithRadius:radius + 10 withIndex:i]],
[NSValue valueWithCGPoint:[self getCoordinatePointForAnimationWithRadius:radius - 5 withIndex:i]],
[NSValue valueWithCGPoint:[self getCoordinatePointForAnimationWithRadius:radius withIndex:i]], nil]];
[moveAnimation setKeyTimes:[NSArray arrayWithObjects:
[NSNumber numberWithFloat:0],
[NSNumber numberWithFloat:0.5],
[NSNumber numberWithFloat:0.75],
[NSNumber numberWithFloat:1.0], nil]];
[moveAnimation setTimingFunctions:[NSArray arrayWithObjects:
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], nil]];
moveAnimation.beginTime = CACurrentMediaTime() + 1 + (0.1 * i);
[layer addAnimation:opacityAnimation forKey:@"opacityAnimationUp"];
[layer addAnimation:moveAnimation forKey:@"moveAnimationUp"];
// That's not working correctly because of the delay
[layer setOpacity:1.0];
[layer setPosition:[self getCoordinatePointForAnimationWithRadius:radius withIndex:i]];
謝謝!來自德國
最好的問候, 克里斯
哇,它已成功。感謝David(+1) –