<!--
{
  "availability" : [
    "macOS: 14.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextLayoutFragment/textLineFragment(forVerticalOffset:requiresExactMatch:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextLayoutFragment(im)textLineFragmentForVerticalOffset:requiresExactMatch:"
  },
  "title" : "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.

```
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

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

## Discussion

Set `requiresExactMatch` to <doc://com.apple.documentation/documentation/Swift/true> to find the text line fragment that contains the vertical offset, or set `requiresExactMatch` to <doc://com.apple.documentation/documentation/Swift/false> to find the closest text line fragment matching or beyond the vertical offset. Returns `nil` if there isn’t a match.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)