<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSegmentedCell",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSegmentedCell"
  },
  "title" : "NSSegmentedCell"
}
-->

# NSSegmentedCell

An `NSSegmentedCell` object implements the appearance and behavior of a horizontal button divided into multiple segments. This class is used in conjunction with the [`NSSegmentedControl`](/documentation/AppKit/NSSegmentedControl) class to implement a segmented control.

```
class NSSegmentedCell
```

## Overview

Use the methods of `NSSegmentedCell` to customize the attributes of a segmented control. To customize the appearance of individual segments, you can also subclass and override the [`drawSegment(_:inFrame:with:)`](/documentation/AppKit/NSSegmentedCell/drawSegment(_:inFrame:with:)) method.

## Topics

### Specifying the Number of Segments

[`segmentCount`](/documentation/AppKit/NSSegmentedCell/segmentCount)

The number of segments in the segmented control.

### Specifying the Selected Segment

[`-  setSelected:forSegment:`](/documentation/AppKit/NSSegmentedCell/setSelected(_:forSegment:))

Sets the selection state of the specified segment.

[`-  selectSegmentWithTag:`](/documentation/AppKit/NSSegmentedCell/selectSegment(withTag:))

Selects the segment with the specified tag.

[`-  makeNextSegmentKey`](/documentation/AppKit/NSSegmentedCell/makeNextSegmentKey())

Selects the next segment.

[`-  makePreviousSegmentKey`](/documentation/AppKit/NSSegmentedCell/makePreviousSegmentKey())

Selects the previous segment.

[`selectedSegment`](/documentation/AppKit/NSSegmentedCell/selectedSegment)

The index of the selected segment of the control, or `-1` if no segment is selected.

[`-  isSelectedForSegment:`](/documentation/AppKit/NSSegmentedCell/isSelected(forSegment:))

Returns a Boolean value indicating whether the specified segment is selected,

### Specifying the Tracking Mode

[`trackingMode`](/documentation/AppKit/NSSegmentedCell/trackingMode)

The tracking mode used for the segments of the control.

### Configuring Individual Segments

[`-  setLabel:forSegment:`](/documentation/AppKit/NSSegmentedCell/setLabel(_:forSegment:))

Sets the label for the specified segment.

[`-  labelForSegment:`](/documentation/AppKit/NSSegmentedCell/label(forSegment:))

Returns the label of the specified segment.

[`-  setImage:forSegment:`](/documentation/AppKit/NSSegmentedCell/setImage(_:forSegment:))

Sets the image for the specified segment.

[`-  imageForSegment:`](/documentation/AppKit/NSSegmentedCell/image(forSegment:))

Returns the image associated with the specified segment.

[`-  setImageScaling:forSegment:`](/documentation/AppKit/NSSegmentedCell/setImageScaling(_:forSegment:))

Sets the image scaling mode for the specified segment.

[`-  imageScalingForSegment:`](/documentation/AppKit/NSSegmentedCell/imageScaling(forSegment:))

Returns the image scaling mode associated with the specified segment.

[`-  setWidth:forSegment:`](/documentation/AppKit/NSSegmentedCell/setWidth(_:forSegment:))

Sets the width of the specified segment.

[`-  widthForSegment:`](/documentation/AppKit/NSSegmentedCell/width(forSegment:))

Returns the width of the specified segment.

[`-  setEnabled:forSegment:`](/documentation/AppKit/NSSegmentedCell/setEnabled(_:forSegment:))

Sets the enabled state of the specified segment

[`-  isEnabledForSegment:`](/documentation/AppKit/NSSegmentedCell/isEnabled(forSegment:))

Returns a Boolean value indicating whether the specified segment is enabled.

[`-  setMenu:forSegment:`](/documentation/AppKit/NSSegmentedCell/setMenu(_:forSegment:))

Sets the menu for the specified segment.

[`-  menuForSegment:`](/documentation/AppKit/NSSegmentedCell/menu(forSegment:))

Returns the menu for the specified segment.

[`-  setToolTip:forSegment:`](/documentation/AppKit/NSSegmentedCell/setToolTip(_:forSegment:))

Sets the tooltip for the specified segment.

[`-  toolTipForSegment:`](/documentation/AppKit/NSSegmentedCell/toolTip(forSegment:))

Returns the tooltip of the specified segment.

[`-  setTag:forSegment:`](/documentation/AppKit/NSSegmentedCell/setTag(_:forSegment:))

Sets the tag for the specified segment.

[`-  tagForSegment:`](/documentation/AppKit/NSSegmentedCell/tag(forSegment:))

Returns the tag of the specified segment.

### Drawing Custom Content

[`-  drawSegment:inFrame:withView:`](/documentation/AppKit/NSSegmentedCell/drawSegment(_:inFrame:with:))

Draws the image and label of the segment in the specified view.

### Specifying Segment Visual Styles

[`-  interiorBackgroundStyleForSegment:`](/documentation/AppKit/NSSegmentedCell/interiorBackgroundStyle(forSegment:))

Returns the interior background style for the specified segment.

[`segmentStyle`](/documentation/AppKit/NSSegmentedCell/segmentStyle)

The visual style used to display the segmented control.

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`NSAccessibilityProtocol`](/documentation/AppKit/NSAccessibilityProtocol)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`NSAccessibilityElementProtocol`](/documentation/AppKit/NSAccessibilityElementProtocol)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSUserInterfaceItemIdentification`](/documentation/AppKit/NSUserInterfaceItemIdentification)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSCoding`](/documentation/Foundation/NSCoding)

### Inherits From

[`NSActionCell`](/documentation/AppKit/NSActionCell)

---

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)