I've seen many examples of how you can convert local point of an UIView to screen coordinate. For example,
CGPoint subContentLocalPoint = subContent.frame.origin ;
CGPoint basePos = [subContent convertPoint:subContentLocalPoint toView:nil] ;
But how does one do the opposite? (i.e. convert screen coordinates to a UIView local point.) For example,
Screen Coordinate - x:90 y:100 UIView content - x:0 y:0 // because this is where the UIView object is on the screen.
Screen coordinates to specific view:
UIView* specificView = ...;
CGPoint pointInScreen = ...;
CGPoint pointInWindow = [specificView.window convertPoint:pointInScreen fromWindow:nil];
CGPoint pointInView = [specificView convertPoint:pointInWindow fromView:nil];
Try this if you want to get screen position from position of subContent.
[subContent convertPoint:subContentLocalPoint fromView:[UIApplication sharedApplication].keyWindow];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With