I’m seeing inconsistent UISegmentedControl background-color behavior on certain devices running iOS 26. The same code works as expected on other devices and iOS versions, but on affected devices the control does not display the assigned backgroundColor.
The issue occurs using standard UIKit colors and does not depend on custom fonts, images, or appearance extensions. Here is a simplified example using only public UIKit APIs:
private let segmentedControl = UISegmentedControl(items: ["Card", "Email"])
private func setupSegmentedControl() {
segmentedControl.selectedSegmentIndex = 0
guard let cardIcon = UIImage(
systemName: "creditcard.fill",
withConfiguration: UIImage.SymbolConfiguration(
pointSize: 14,
weight: .semibold
)
),
let emailIcon = UIImage(
systemName: "envelope.fill",
withConfiguration: UIImage.SymbolConfiguration(
pointSize: 14,
weight: .semibold
)
) else {
return
}
segmentedControl.setImage(
cardIcon,
forSegmentAt: 0
)
segmentedControl.setImage(
emailIcon,
forSegmentAt: 1
)
segmentedControl.backgroundColor = .systemGray5
segmentedControl.selectedSegmentTintColor = .systemBlue
segmentedControl.layer.cornerRadius = 8
segmentedControl.clipsToBounds = true
let font = UIFont.systemFont(
ofSize: 14,
weight: .medium
)
segmentedControl.setTitleTextAttributes(
[
.foregroundColor: UIColor.label,
.font: font
],
for: .normal
)
segmentedControl.setTitleTextAttributes(
[
.foregroundColor: UIColor.white,
.font: font
],
for: .selected
)
segmentedControl.addTarget(
self,
action: #selector(segmentChanged(_:)),
for: .valueChanged
)
view.addSubview(segmentedControl)
}
@objc private func segmentChanged(
_ sender: UISegmentedControl
) {
print("Selected segment: \(sender.selectedSegmentIndex)")
}
UISegmentedControl Apple Documentation
0
0
36