CGPointをあるビューから別のビューに移動するときにアニメーションを実行しようとしていますが、ポイントを参照する座標を見つける必要があります。最初にアニメーションを行うことができます。アニメーションのあるビューから別のビューへCGPointsを相対的に変換する
ビュー2にポイント(24,15)があり、それをビュー1にアニメーションしたいとします。ポイントを追加する際に、ポイントの値を新しいビュー内に保持したいとします新しいビューのサブビューとして、私はトゥイーンを行うことができるので、ポイントがどこになるのかを知る必要があります。
このグラフを参照してください:
今、これは私がやろうとしているものです:
customObject *lastAction = [undoStack pop];
customDotView *aDot = lastAction.dot;
CGPoint oldPoint = aDot.center;
CGPoint newPoint = lastAction.point;
newPoint = [lastAction.view convertPoint:newPoint toView:aDot.superview];
CABasicAnimation *anim4 = [CABasicAnimation animationWithKeyPath:@"position"];
anim4.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
anim4.fromValue = [NSValue valueWithCGPoint:CGPointMake(oldPoint.x, oldPoint.y)];
anim4.toValue = [NSValue valueWithCGPoint:CGPointMake(newPoint.x, newPoint.y)];
anim4.repeatCount = 0;
anim4.duration = 0.1;
[aDot.layer addAnimation:anim4 forKey:@"position"];
[aDot removeFromSuperview];
[lastAction.view addSubview:aDot];
[lastAction.view bringSubviewToFront:aDot];
aDot.center = newPoint;
任意のアイデア?
両方のビューが表示されていますか?彼らはより大きな視野に入っていますか? –