---
title: "textLineFragment(forVerticalOffset:requiresExactMatch:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nstextlayoutfragment/textlinefragment(forverticaloffset:requiresexactmatch:)"
---

# textLineFragment(forVerticalOffset:requiresExactMatch:)

Returns the text line fragment for the vertical offset you provide, or the closest text line fragment beyond the vertical offset.

## Declaration

```swift
func textLineFragment(forVerticalOffset verticalOffset: CGFloat, requiresExactMatch: Bool) -> NSTextLineFragment?
```

## Parameters

- `verticalOffset`: A float value that indicates a vertical distance, expressed in points, from the layout fragment frame’s origin.
- `requiresExactMatch`: A Boolean value that indicates whether the method returns an exact match, or returns the closest match if there isn’t an exact match. The default value is doc://com.apple.documentation/documentation/Swift/true.

## Return Value

Return Value A text line fragment, or nil if there isn’t a match.

## Discussion

Discussion Set requiresExactMatch to true to find the text line fragment that contains the vertical offset, or set requiresExactMatch to false to find the closest text line fragment matching or beyond the vertical offset. Returns nil if there isn’t a match.

## See Also

### Getting line fragments

- [textLineFragments](uikit/nstextlayoutfragment/textlinefragments.md)
- [NSTextLayoutFragment.EnumerationOptions](uikit/nstextlayoutfragment/enumerationoptions.md)
- [textLineFragment(for:isUpstreamAffinity:)](uikit/nstextlayoutfragment/textlinefragment(for:isupstreamaffinity:).md)
