0330--iOS之UITouch类

Class

UITouch

An object representing the location, size, movement, and force of a touch occurring on the screen.

         --一个表示屏幕上的触摸的对象,包含了触摸的位置、尺寸、移动、力度。

Declaration

class UITouch : NSObject

Overview

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

        --您可以通过UIEvent对象来访问touch对象,Event对象是用于处理事件的。触摸对象内部的访问方法,用于:

  • The view or window in which the touch occurred
    --访问触摸发生所在的view或者window

  • The location of the touch within the view or window
    --访问触摸在view或window中的位置

  • The approximate radius of the touch
    --访问触摸的大致半径

  • The force of the touch (on devices that support 3D Touch or Apple Pencil)
    --访问触摸的力度(在支持3D触摸或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 UIKit Apps.

A touch object persists throughout a multi-touch sequence. You may store a reference to a touch while handling a multi-touch sequence, as long as you release that reference when the sequence ends. If you need to store information about a touch outside of a multi-touch sequence, 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的gestureRecognizers属性包含了当前在处理触摸的手势识别器。每个手势识别器都是UIGestureRecognizer的一个具体子类的实例。       

 

Topics                    --专题

Getting the Location of a Touch                       --获取touch的位置

 

func location(in: UIView?) -> CGPoint

Returns the current location of the receiver in the coordinate system of the given view.

func previousLocation(in: UIView?) -> CGPoint

Returns the previous location of the receiver in the coordinate system of the given view.

var view: UIView?

The view to which touches are being delivered, if any.

var window: UIWindow?

The window in which the touch initially occurred.

var majorRadius: CGFloat

The radius (in points) of the touch.

var majorRadiusTolerance: CGFloat

The tolerance (in points) of the touch’s radius.

func preciseLocation(in: UIView?) -> CGPoint

Returns a precise location for the touch, when available.

func precisePreviousLocation(in: UIView?) -> CGPoint

Returns a precise previous location for the touch, when available.

 

Getting Touch Attributes                --获取touch的特征

var tapCount: Int

The number of times the finger was tapped for this given touch.

var timestamp: TimeInterval

The time when the touch occurred or when it was last mutated.

var type: UITouch.TouchType

The type of the touch.

enum UITouch.TouchType

The type of touch received.

var phase: UITouch.Phase

The phase of the touch.

enum UITouch.Phase

The phase of a finger touch.

var force: CGFloat

The force of the touch, where a value of 1.0 represents the force of an average touch (predetermined by the system, not user-specific).

var maximumPossibleForce: CGFloat

The maximum possible force for a touch.

var altitudeAngle: CGFloat

The altitude (in radians) of the stylus.

func azimuthAngle(in: UIView?) -> CGFloat

Returns the azimuth angle (in radians) of the stylus.

func azimuthUnitVector(in: UIView?) -> CGVector

Returns a unit vector that points in the direction of the azimuth of the stylus.

 

Managing Estimated Touch Attributes                           --管理touch的估计特征

var estimatedProperties: UITouch.Properties

A set of touch properties whose values contain only estimates.

var estimatedPropertiesExpectingUpdates: UITouch.Properties

The set of touch properties for which updated values are expected in the future.

struct UITouch.Properties

A bit mask of touch properties that may get updated.

var estimationUpdateIndex: NSNumber?

An index number that lets you correlate an updated touch with the original touch.

 

Getting a Touch Object’s Gesture Recognizers                       --获取touch的手势识别器

var gestureRecognizers: [UIGestureRecognizer]?

The gesture recognizers that are receiving the touch object.

 

Working with Touch Events in Sprite Kit                         --在Sprite Kit  中使用touch

func location(in: SKNode) -> CGPoint

Returns the current location of the receiver in the coordinate system of the given node.

func previousLocation(in: SKNode) -> CGPoint

Returns the previous location of the receiver in the coordinate system of the given node.

Relationships

Inherits From

NSObject

Conforms To

See Also

Touches

 

Handling Touches in Your View

Use touch events directly on a view subclass if touch handling is intricately linked to the view's content.

 

Handling Input from Apple Pencil

Learn how to detect and respond to touches from Apple Pencil.

 

Tracking the Force of 3D Touch Events

Manipulate your content based on the force of touches.

 

Illustrating the Force, Altitude, and Azimuth Properties of Touch Input

Capture Apple Pencil and touch input in views.

 

Leveraging Touch Input for Drawing Apps

Capture touches as a series of strokes and render them efficiently on a drawing canvas.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值