---
title: "drawSegment(_:inFrame:with:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nssegmentedcell/drawsegment(_:inframe:with:)"
---

# drawSegment(_:inFrame:with:)

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

## Declaration

```swift
func drawSegment(_ segment: Int, inFrame frame: NSRect, with controlView: NSView)
```

## Parameters

- `segment`: The index of the segment to draw. This method raises an exception (doc://com.apple.documentation/documentation/Foundation/NSExceptionName/rangeException) if the index is out of bounds.
- `frame`: The rectangle in which to draw the segment’s image and label. This rectangle is specified in user space coordinates of the specified view.
- `controlView`: The view that contains the segment.

## Discussion

Discussion You can override this method to provide a custom appearance for segmented controls. You should not call this method directly. It is called for you automatically by the control when it needs to be redrawn.

## See Also

### Related Documentation

- [draw(withFrame:in:)](appkit/nscell/draw(withframe:in:).md)
