iOS - Get location of a view in a window?
Use can use the UIView method covertRect:toView to convert to the new co-ordinate space. I did something very similar:
// Convert the co-ordinates of the view into the window co-ordinate space
CGRect newFrame = [self convertRect:self.bounds toView:nil];
// Add this view to the main window
[self.window addSubview:self];
self.frame = newFrame;
In my example, self is a view that is being removed from its superView and added to the window over the top of where it was. The nil parameter in the toView: means use the window rather than a specific view.
Hope this helps,
Dave
You can ask your .superview
to convert your origin
for you for you
CGPoint originGlobal = [myView.superview convertPoint:myView.frame.origin
toView:nil];