UITouch

A UITouch object represents the location, size, movement, and force of a finger on the screen for a particular event. The force of a touch is available starting in iOS 9 on devices that support 3D Touch or Apple Pencil.

You access touch objects through UIEvent objects passed into responder objects for event handling. A touch object includes accessors for:

  • The view or window in which the touch occurred 

  • The location of the touch within the view or window 

  • The approximate radius of the touch 

  • The force of the touch (on devices that support 3D Touch or Apple Pencil) 

A touch object also contains a timestamp indicating when the touch occurred, an integer representing the number of times the user tapped the screen, and the phase of the touch in the form of a constant that describes whether the touch began, moved, or ended, or whether the system canceled the touch.

To learn how to work with swipes, read Handling Swipe and Drag Gestures in Event Handling Guide for iOS.

A touch object persists throughout a multi-touch sequence. Never retain a touch object when handling an event. If you need to keep information about a touch from one touch phase to another, copy that information from the touch.

The gestureRecognizers property of a touch contains the gesture recognizers currently handling the touch. Each gesture recognizer is an instance of a concrete subclass of UIGestureRecognizer.


你可能感兴趣的:(UITouch)