So, we have a let's call it small view that has a certain point inside it. That point has local coordinates relative to its parent view that is small view.
Now, we want to know, what would be the coordinates of that point if it would stay in the same spot on the screen, but it would be part of the root view. (this effectively gives us the coordinates relative to the whole screen.)
You will calculate the global coordinates of that point
CGPoint globalCoordinates = [self.smallView convertPoint:localCoordinatesOfThePoint
toView:self.view];
localCoordinatesOfThePoint
is also a CGPoint structure.
Another scenario
is when you have the whole screen covered with root view, this has a large view, (still smaller than the root view though), and this large view has a small view as a subview inside it.
You will calculate the position of the small view's tip
CGPoint originOnScreen = [self.smallView convertPoint:self.smallview.origin
toView:self.view];
self.smallview.origin
is a CGPoint relative to Large view. Thus, we calculate, what would be its coordinates if this point (it's the top-left tip of small view really) would be inside the root view.
CATCH
If the root view is not full screen, than instead of root view ,we need to get a reference to the main window as this will be our view against which we calculate coordinates now.
we have to
#import "AppDelegate.h"
in our class where we calculate and then pass the window property as the reference view. It is guaranteed that window covers the screen and UIWindow is a subclass of UIView. So it just works.
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
CGPoint originOnScreen = [self.smallView convertPoint:self.smallview.origin
toView:appDelegate.window];