0

オブジェクト (UIImageView) をポイント A からポイント B に移動し、ポイント B で画像を 180 度回転させて反対方向に向け、オブジェクトを B から A (後方) に移動する必要があります。

AからBに移動する以下のコードがあります。UIImageViewを回転させる方法も知っています。しかし、オブジェクトがポイント B に到達したことを知る方法と、画面上に多くのオブジェクトがあることを考慮して回転アクションを適用する方法は?

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation    animationWithKeyPath:@"position"];
pathAnimation.duration = speed;
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO; 
CGMutablePathRef pointPath = CGPathCreateMutable();
CGPathMoveToPoint(pointPath, NULL, rect.origin.x, rect.origin.y);
CGPathAddLineToPoint(pointPath, NULL, x, y);
pathAnimation.path = pointPath;
CGPathRelease(pointPath);   
[imageView.layer addAnimation:pathAnimation forKey:[NSString    stringWithFormat:@"pathAnimation%@",objId]];
[imageView release];
4

2 に答える 2

1

CAAnimationオブジェクトにデリゲートを設定し、デリゲートにanimationDidStop:finished:メソッドを実装します。

OTOH、あなたが説明したアニメーションは、UIViewのアニメーションサポートで十分簡単に​​実行できるように聞こえます。4.0以降をターゲットにしている場合は、ブロックを使用したビューのアニメーション化を参照してください。以前のバージョンをターゲットにしている場合は、ビューのアニメーション化を参照してください。

于 2011-08-31T15:02:32.113 に答える
1

CAAnimationデリゲートメソッドを使用できます

-(void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
于 2011-08-31T14:58:27.170 に答える