<!--
{
  "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(with:at:animated:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UISegmentedControl(im)insertSegmentWithImage:atIndex:animated:"
  },
  "title" : "insertSegment(with:at:animated:)"
}
-->

# insertSegment(with:at:animated:)

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

```
func insertSegment(with image: UIImage?, at segment: Int, animated: Bool)
```

## Parameters

`image`

An image object to use as the content of the segment.

`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 segmented control inserts the new segment immediately before the designated one.

`animated`

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

---

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)