Get UIButton inside absolute location of UIScrollView

It may be a question with dum, but I can not find the answer to this question ...

I have a UIScrollView and inside several UIButtons. When I press a button, I want to know the location of the screen on the button. If I use button.frame, it gives me a position inside a UIScrollView, which is normal.

How can I find x and y relative to the screen of a pressed button?

Thanks in advance.

+4
source share
1 answer

Your objection was correct - use instead

- (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view 

from a UIView for example

 [button.superview convertPoint:button.frame.origin toView:nil]; 

Not verified, but I believe this should work. Also see iPhone - Get a UIView Position Within an Entire UIWindow

+11
source

Source: https://habr.com/ru/post/1347606/


All Articles