---
title: NSRulerView
framework: appkit
role: symbol
role_heading: Class
path: appkit/nsrulerview
---

# NSRulerView

A ruler and the markers above or to the side of a scroll view’s document view.

## Declaration

```swift
class NSRulerView
```

## Overview

Overview Views within the scroll view can become clients of the ruler view, having it display markers for their elements, and receiving messages from the ruler view when the user manipulates the markers. Principal Attributes Displays markers that represent elements of the client view. Displays in arbitrary units. Provides for an accessory view containing extra controls. Creation hasHorizontalRuler (NSScrollView) hasVerticalRuler (NSScrollView) init(scrollView:orientation:) Designated initializer. Commonly Used Methods Overview See NSRulerMarkerClientViewDelegation for delegate methods that may be of interest.

## Topics

### Creating a Ruler View

- [init(scrollView:orientation:)](appkit/nsrulerview/init(scrollview:orientation:).md)
- [init(coder:)](appkit/nsrulerview/init(coder:).md)

### Altering measurement units

- [registerUnit(withName:abbreviation:unitToPointsConversionFactor:stepUpCycle:stepDownCycle:)](appkit/nsrulerview/registerunit(withname:abbreviation:unittopointsconversionfactor:stepupcycle:stepdowncycle:).md)
- [measurementUnits](appkit/nsrulerview/measurementunits.md)
- [NSRulerView.UnitName](appkit/nsrulerview/unitname.md)

### Setting the client view

- [clientView](appkit/nsrulerview/clientview.md)

### Setting an accessory view

- [accessoryView](appkit/nsrulerview/accessoryview.md)

### Setting the zero mark position

- [originOffset](appkit/nsrulerview/originoffset.md)

### Adding and removing markers

- [markers](appkit/nsrulerview/markers.md)
- [addMarker(_:)](appkit/nsrulerview/addmarker(_:).md)
- [removeMarker(_:)](appkit/nsrulerview/removemarker(_:).md)
- [trackMarker(_:withMouseEvent:)](appkit/nsrulerview/trackmarker(_:withmouseevent:).md)

### Drawing temporary ruler lines

- [moveRulerline(fromLocation:toLocation:)](appkit/nsrulerview/moverulerline(fromlocation:tolocation:).md)

### Drawing

- [drawHashMarksAndLabels(in:)](appkit/nsrulerview/drawhashmarksandlabels(in:).md)
- [drawMarkers(in:)](appkit/nsrulerview/drawmarkers(in:).md)
- [invalidateHashMarks()](appkit/nsrulerview/invalidatehashmarks().md)

### Ruler layout

- [scrollView](appkit/nsrulerview/scrollview.md)
- [orientation](appkit/nsrulerview/orientation-swift.property.md)
- [NSRulerView.Orientation](appkit/nsrulerview/orientation-swift.enum.md)
- [reservedThicknessForAccessoryView](appkit/nsrulerview/reservedthicknessforaccessoryview.md)
- [reservedThicknessForMarkers](appkit/nsrulerview/reservedthicknessformarkers.md)
- [ruleThickness](appkit/nsrulerview/rulethickness.md)
- [requiredThickness](appkit/nsrulerview/requiredthickness.md)
- [baselineLocation](appkit/nsrulerview/baselinelocation.md)
- [isFlipped](appkit/nsrulerview/isflipped.md)

## Relationships

### Inherits From

- [NSView](appkit/nsview.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSAccessibilityElementProtocol](appkit/nsaccessibilityelementprotocol.md)
- [NSAccessibilityProtocol](appkit/nsaccessibilityprotocol.md)
- [NSAnimatablePropertyContainer](appkit/nsanimatablepropertycontainer.md)
- [NSAppearanceCustomization](appkit/nsappearancecustomization.md)
- [NSCoding](foundation/nscoding.md)
- [NSDraggingDestination](appkit/nsdraggingdestination.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSStandardKeyBindingResponding](appkit/nsstandardkeybindingresponding.md)
- [NSTouchBarProvider](appkit/nstouchbarprovider.md)
- [NSUserActivityRestoring](appkit/nsuseractivityrestoring.md)
- [NSUserInterfaceItemIdentification](appkit/nsuserinterfaceitemidentification.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Rulers

- [NSRulerMarker](appkit/nsrulermarker.md)
