Reputation: 51
I need to know the absolute position of my UILabel in the window coordinates. This UILabel (in the code below, uil) is located inside a view at 34 x 174 y of the view coordinate system)
I see that many psay that convertPoint should be used to get the absolute values. But after convertion I get a CGPoint that is still at 34 x 174 y. While I expected coordinates referring to the screen window.
Could you explain to me what I am doing wrong and how to get the window coordinates of my label?
CGPoint cgp = [uil convertPoint:uil.frame.origin fromView:nil];
Thanks
Upvotes: 1
Views: 1794
Reputation: 31016
The documentation for convertPoint:toView:
says, "If view is nil, this method instead converts to window base coordinates." It sounds like you want that rather than fromView:
.
Upvotes: 1