How can I get touch offset when using UITouch? I am doing a project like a remote control. I have a view set to multi-touched and I want the view to act like a touch pad for Mac, so I need the touch offsets when people move to control the mouse. Any ideas?
How can I get touch offset when using UITouch ? I am doing a
Share
This can be accomplished with a
UIPanGestureRecognizerby measuring the diagonal distance from the center of the screen to the current touch location.Declare the gesture and hook it to
self.viewso that the entire screen responds to touch events.Then in this method, we use the gesture recognizers state:
UIGestureRecognizerStateChangedto update and integer that measures the diagonal distance between touch location and screen center as the touch location changes.