0

ビューを移動するこのコードがあります。

CABasicAnimation *theAnimation; 
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
theAnimation.duration=1;
theAnimation.repeatCount=1;
theAnimation.autoreverses=NO;
theAnimation.fromValue=[NSNumber numberWithFloat:0];
theAnimation.toValue=[NSNumber numberWithFloat:-60];
[view.layer addAnimation:theAnimation forKey:@"animateLayer"];

問題は、アニメーションの終了後にビューの実際の座標がリセットされることです。アニメーションが終了した後、ビューが新しい座標にとどまる可能性はありますか?

ありがとう。

4

1 に答える 1

0

プロパティをアニメーション化するアニメーションを添付するだけでなく、実際にプロパティを最終的な値に設定する必要があります。クレイジーですね。アニメーションを追加する前に、次のことを試してください。

[view.layer setValue:[NSNumber numberWithFloat:-60] forKey:@"transform.translation.x"];

WWDC 2011 のビデオ「Core Animation Essentials」を見ることを強くお勧めします。これについて説明し、Core Animation を使用しているすべての人に役立つ多くの情報をカバーしています。ここで見つけることができます: https://developer.apple.com/videos/wwdc/2011/

于 2012-01-13T20:29:33.087 に答える