Contents

caretRect(for:)

Returns a rectangle to draw the caret at a specified insertion point.

Declaration

func caretRect(for position: UITextPosition) -> CGRect

Parameters

  • position:

    An object that identifies a location in a text input area.

Return Value

A rectangle that defines the area for drawing the caret.

Discussion

The system uses this value to calculate the length of the beam—the vertical line representing the pointer—when using a trackpad to interact with a text input area. You must implement this method even if text never becomes editable, and an insertion point caret never appears.

See Also

Related Documentation

Providing the caret layout information