Contents

position(from:offset:)

Returns the text position at a specified offset from another text position.

Declaration

func position(from position: UITextPosition, offset: Int) -> UITextPosition?

Parameters

  • position:

    A custom Uitextposition object that represents a location in a document.

  • offset:

    A character offset from position. It can be a positive or negative value.

Return Value

A custom UITextPosition object that represents the location in a document that is at the specified offset from position. Return nil if the computed text position is less than 0 or greater than the length of the backing string.

Discussion

For an example of an implementation of this method, see Using Text Kit to Draw and Manage Text in Text Programming Guide for iOS.

See Also

Computing text ranges and text positions