---
title: "removeSegment(at:animated:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uisegmentedcontrol/removesegment(at:animated:)"
---

# removeSegment(at:animated:)

Removes the segment you specify from the segmented control, optionally animating the transition.

## Declaration

```swift
func removeSegment(at segment: Int, animated: Bool)
```

## Parameters

- `segment`: An index number identifying a segment in the control. It must be a number between 0 and the number of segments (doc://com.apple.uikit/documentation/UIKit/UISegmentedControl/numberOfSegments) minus 1; the segmented control pins values exceeding this upper range to the last segment.
- `animated`: doc://com.apple.documentation/documentation/Swift/true if the removal of the new segment must animate; otherwise, doc://com.apple.documentation/documentation/Swift/false.

## See Also

### Managing segments

- [numberOfSegments](uikit/uisegmentedcontrol/numberofsegments.md)
- [segmentIndex(identifiedBy:)](uikit/uisegmentedcontrol/segmentindex(identifiedby:).md)
- [insertSegment(action:at:animated:)](uikit/uisegmentedcontrol/insertsegment(action:at:animated:).md)
- [insertSegment(with:at:animated:)](uikit/uisegmentedcontrol/insertsegment(with:at:animated:).md)
- [insertSegment(withTitle:at:animated:)](uikit/uisegmentedcontrol/insertsegment(withtitle:at:animated:).md)
- [removeAllSegments()](uikit/uisegmentedcontrol/removeallsegments().md)
- [selectedSegmentIndex](uikit/uisegmentedcontrol/selectedsegmentindex.md)
- [noSegment](uikit/uisegmentedcontrol/nosegment.md)
