Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert window coordinates relative to a specific view?

Example: I have a CGPoint in window coordinates:

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

There is aView which has a superview in a superview in a superview. Somewhere deep in the view hierarchy, probably even transformed a few times.

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

I need pretty much the same thing. Is there an easy way to accomplish that?

like image 509
dontWatchMyProfile Avatar asked May 25 '10 17:05

dontWatchMyProfile


1 Answers

I found a really easy solution:

[self.aView convertPoint:windowPoint fromView:self.window];
like image 134
dontWatchMyProfile Avatar answered Oct 18 '22 04:10

dontWatchMyProfile