<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UISegmentedControl/insertSegment(withTitle:at:animated:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UISegmentedControl(im)insertSegmentWithTitle:atIndex:animated:"
  },
  "title" : "insertSegment(withTitle:at:animated:)"
}
-->

# insertSegment(withTitle:at:animated:)

Inserts a segment at the position you specify and gives it a title as content.

```
func insertSegment(withTitle title: String?, at segment: Int, animated: Bool)
```

## Parameters

`title`

A string to use as the segment’s title.

`segment`

An index number identifying a segment in the control.

    `segment`     must be a number in the range 0 to the number of segments ([`numberOfSegments`](/documentation/UIKit/UISegmentedControl/numberOfSegments)    ) inclusive; the segmented control pins values exceeding this upper range to the last segment.

    The method inserts the new segment just before the designated one.

`animated`

<doc://com.apple.documentation/documentation/Swift/true> if the insertion of the new segment must be animated, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

---

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)