Instance Method

location(in:)

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

Declaration

func location(in view: UIView?) -> CGPoint

Parameters

view

The view object in whose coordinate system you want the touch located. A custom view that is handling the touch may specify self to get the touch location in its own coordinate system. Pass nil to get the touch location in the window’s coordinates.

Return Value

A point specifying the location of the receiver in view.

Discussion

This method returns the current location of a UITouch object in the coordinate system of the specified view. Because the touch object might have been forwarded to a view from another view, this method performs any necessary conversion of the touch location to the coordinate system of the specified view.

See Also

Getting the Location of a Touch

func previousLocation(in: UIView?)

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?)

Returns a precise location for the touch, when available.

func precisePreviousLocation(in: UIView?)

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