<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutManager/rulerAccessoryView(for:paragraphStyle:ruler:enabled:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutManager(im)rulerAccessoryViewForTextView:paragraphStyle:ruler:enabled:"
  },
  "title" : "rulerAccessoryView(for:paragraphStyle:ruler:enabled:)"
}
-->

# rulerAccessoryView(for:paragraphStyle:ruler:enabled:)

Returns the accessory view that the text system uses for its ruler.

```
func rulerAccessoryView(for view: NSTextView, paragraphStyle style: NSParagraphStyle, ruler: NSRulerView, enabled isEnabled: Bool) -> NSView?
```

## Parameters

`view`

The text view using the layout manager.

`style`

Sets the state of the controls in the accessory view; must not be `nil`.

`ruler`

The ruler view whose accessory view is returned.

`isEnabled`

If <doc://com.apple.documentation/documentation/Swift/true>, the accessory view is enabled and accepts mouse and keyboard events; if <doc://com.apple.documentation/documentation/Swift/false> it’s disabled.

## Return Value

The accessory view containing tab wells, text alignment buttons, and so on.

## Discussion

If you have turned off automatic ruler updating through the use of [`usesRuler`](/documentation/AppKit/NSTextView/usesRuler) so that you can do more complex things, but you still want to display the appropriate accessory view, you can use this method.

This method is invoked automatically by the [`NSTextView`](/documentation/AppKit/NSTextView) object using the layout manager. You should rarely need to invoke it, but you can override it to customize ruler support. If you do use this method directly, note that it neither installs the ruler accessory view nor sets the markers for the [`NSRulerView`](/documentation/AppKit/NSRulerView) object. You must install the accessory view into the ruler using the [`NSRulerView`](/documentation/AppKit/NSRulerView) method [`accessoryView`](/documentation/AppKit/NSRulerView/accessoryView). To set the markers, use [`rulerMarkers(for:paragraphStyle:ruler:)`](/documentation/AppKit/NSLayoutManager/rulerMarkers(for:paragraphStyle:ruler:)) to get the markers needed, and then send [`markers`](/documentation/AppKit/NSRulerView/markers) to the ruler.

---

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)