How to convert the coordinates of the window relative to a specific view?

Example: I have CGPoint in window coordinates:

CGPoint windowPoint = CGPointMake(220.0f, 400.0f);

There is aViewone that has a supervisor in a supervisor in supervision. Somewhere deep in the hierarchy of ideas, perhaps even several times transformed.

When you get UITouch, you can request it for -locationInView: and it will return the coordinates relative to this view.

I need almost the same thing. Is there an easy way to do this?

+5
source share
2 answers

I found a very simple solution:

[self.aView convertPoint:windowPoint fromView:self.window];
+11
source

, , subviews subview frame.origin, windowPoint frame.origin.

0

All Articles