enumerateTextSegments(in:type:options:using:)
Enumerates text segments of a specific type and in the text range you provide.
Declaration
func enumerateTextSegments(in textRange: NSTextRange, type: NSTextLayoutManager.SegmentType, options: NSTextLayoutManager.SegmentOptions = [], using block: (NSTextRange?, CGRect, CGFloat, NSTextContainer) -> Bool)Parameters
- textRange:
The range as an Nstextrange.
- type:
One of the available Segmenttype values.
- options:
One or more of the Segmentoptions options.
- block:
A closure you provide to determine if the enumeration finishes early.
Discussion
A text segment is a logically and visually contiguous portion of the text content inside a line fragment that you specify with a single text range. The framework enumerates the segments visually from left to right. Returning false breaks out of the enumeration.