UISegmentedControl tap position misalignment in Xcode 26 with UIDesignRequiresCompatibility enabled

Environment

  • macOS 15.7.3
  • Xcode 26.1.1 / 26.2
  • iOS 18.5 / 26.2
  • iPhone 16 Pro Simulator and physical device

Problem Description

When tapping an unselected UISegmentedControl, the selected segment does not match the tapped position. Specifically, tapping the rightmost segment (index: 3) results in the leftmost segment (index: 0) being selected instead.

Conditions for Reproduction

This issue occurs when all of the following conditions are met:

  1. Built with Xcode 26.x
  2. UIDesignRequiresCompatibility is set to YES in Info.plist
  3. UISegmentedControl is positioned using Auto Layout with leading alignment
  4. Segments are added dynamically using insertSegment(withTitle:at:animated:)

Note: The issue does not occur when segments are defined statically in Storyboard.

Steps to Reproduce

  1. Create a subclass of UISegmentedControl that dynamically sets segments:
class CustomSegmentedControl: UISegmentedControl {
    func setSegments(titles: [String]) {
        removeAllSegments()
        titles.forEach { title in
            insertSegment(withTitle: title, at: numberOfSegments, animated: false)
        }
    }
}
  1. In the ViewController, configure the control:
override func viewDidLoad() {
    super.viewDidLoad()
    
    segmentedControl.setSegments(titles: ["Item A", "Item B", "Item C", "Item D"])
    segmentedControl.selectedSegmentIndex = UISegmentedControl.noSegment
}
  1. Set UIDesignRequiresCompatibility to YES in Info.plist:
<key>UIDesignRequiresCompatibility</key>
<true/>
  1. Run the app and tap the rightmost segment ("Item D")

Expected vs Actual Behavior

ExpectedActual
Tap rightmost segment"Item D" (index: 3) is selected"Item A" (index: 0) is selected

What I Tried (Did Not Work)

Calling layoutIfNeeded() after adding segments:

segmentedControl.setSegments(titles: ["Item A", "Item B", "Item C", "Item D"])
segmentedControl.layoutIfNeeded()  // No effect

Workarounds

  1. Set UIDesignRequiresCompatibility to NO (enables Liquid Glass design)
  2. Define segments statically in Storyboard instead of dynamically

Sample Project

Minimal reproduction project is available here: https://github.com/CH3COOH/Samples/tree/master/SampleSelectSegmentedControl

Feedback Assistant

This issue has been reported via Feedback Assistant: FB21712773


Has anyone else encountered this issue or found alternative workarounds?

UISegmentedControl tap position misalignment in Xcode 26 with UIDesignRequiresCompatibility enabled
 
 
Q