I'm trying to do an animation where I move one CGPoint from one view to another, I want to find the coordinates where the point is going to be in reference to the first so I can do the animation.

So let's say I have a point (24,15) in view2 and I'd like to animate it to view1, I still want to keep the value of the point within the new view as I'm adding the point as a subview of the new view, but for the animation I need to know the value of where the point would be so I can do a tween.

Please refer to this graph:

enter image description here

Now this is what I'm trying to do:

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;

Any ideas?

Edit
Report