Subclassing UISegmentedControl in Xcode 26 strange behavior

UIKit application.

I have a UISegmentedControl which displays flags, using the emoji for the text of the segment (SegmentedControl defined in stroryboard).

Depending app is in Portrait or Landscape, the segmented control is displayed vertically or horizontally.

When horizontal, nothing to do, direct display from stroryboard, works as expected.

When vertical (Portrait), I have to rotate the UISegmentedControl π/2. And To get the flags properly oriented, I rotate each image -π/2.

That works fine when compiling with Xcode 16.4.

But when compiling with Xcode 26.3, rotation of segments do not work.

Here is the illustration, compile on target simulators 26.2 in both cases (3rd image explained below):

                            Xcode 16.4           -               Xcode 26.3 subviews rotated   -     removed subviews rotation

Now the code.

I subclassed UISegmentedControl to draw at will.

class SegmentedControlRotable: UISegmentedControl {

    @IBInspectable var vertical : Bool = false // IBInspectable is now ignored

    override func draw(_ rect: CGRect) {
        if vertical {
            self.transform = CGAffineTransform(rotationAngle: CGFloat.pi / 2.0)
            for subview in self.subviews {
                subview.transform = CGAffineTransform(rotationAngle: -CGFloat.pi / 2.0) // reverse rotate // 3rd picture: this line commented out.
            }
        } else { // does no change
            self.transform = CGAffineTransform(rotationAngle: 0.0)
            for subview in self.subviews {
                subview.transform = CGAffineTransform(rotationAngle: 0.0)
            }
        }
    }

// More code with touchesEnded, works OK in both cases 
}

In fact, with Xcode 26, segments are always drawn on an horizontal line. l I noticed that the structure of self.subviews is different. 19 subviews in Xcode 16, 12 in Xcode 26.

I removed the rotation of subviews, and it's OK. Just flags are now vertical (as illustrated above).

What do I miss ? How to rotate the subviews in Xcode 26 ?

Subclassing UISegmentedControl in Xcode 26 strange behavior
 
 
Q