It's quite unintuitive (and undocumented) that by doing:
segmentedControl.selectedSegmentIndex = 0
nothing happens in the UI (actually something happens but it's quite glitchy) and the way it works is by doing
segmentedControl.setSelectedSegmentIndex(0, animated: true)
Is this on purpose?