I want a view to maintain center between two other views but also move freely, adding it’s own transform to the “centering” transform. Maybe it can be summed up by saying: The view starts at zero, Then the transform that makes it centered is applied. Then it’s local transform is added
Explanation: I have three views that I’ll call One, Two and Three. All three views can be moved via pan gesture recognizer.
If view One moves, both Two and Three follow using basically the code below in my handlePan method:
if (recognizer.view == One){
Two.center = CGPointMake(Two.center.x + translation.x, Two.center.y + translation.y);
Three.center = CGPointMake(Three.center.x + translation.x, Three.center.y + translation.y);
}
View Three maintains center between One and Two via the code below in my handlePan method:
float midX = (One.center.x + Two.center.x)/2;
float midY = (One.center.y + Two.center.y)/2;
Three.center = CGPointMake(midX + translation.x, midY+ translation.y);
All this works just fine. The issue is I want view three to move “free” and also maintain that center, but with it’s own transformation added. See the illo as it might be easier to see what I want to do.

I tried the following setup, but it’s not quite there:
if (recognizer.view == One){
Two.center = CGPointMake(Two.center.x + translation.x, Two.center.y + translation.y);
Three.center = CGPointMake(Three.center.x + translation.x, Three.center.y + translation.y);
} else if (recognizer.view == Two) {
float midX = (One.center.x + Two.center.x)/2;
float midY = (One.center.y + Two.center.y)/2;
Three.center = CGPointMake(midX + translation.x, midY+ translation.y);
}
Thanks for reading!
I worked it out. Pretty simple. Just created a point (here I used two floats numX and numY) to store the translation produced by view Three and the gesture recognizer. Then apply that when moving view Two. This code is in my
handlePanmethod: