07-19-2023, 12:22 AM
iOS 13 introduced some changes to the UISegmentedControl including a really nice animation when switching the selected segment. However I'm noticing that it's not displaying the `backgroundColor` property correctly, it always seems to have a bit of a tint to it.
I've seen questions that answer how to set the `selectedSegmentTintColor` and such but I'm struggling to set the `backgroundColor` to say `.white`, no matter what I do it always shows up a bit of a gray even though there's no `tintColor` or similar setting applied. Setting the `backgroundColor` to other colors shows the same behavior but its most obvious with white. Adding to the mystery is that while this difference shows up on both iOS 13 simulators and a physical device running iOS 13, the visual debugger (in XCode 11 GM2) does not show this difference!
Here's a couple screenshots showing that even though the `backgroundColor` of the `UISegmentedControl` is set to the same as the `backgroundColor` of the view shown behind it they are slightly different.
Device running iOS 13 (white backgroundColor)
[![enter image description here][1]][1]
Same view/code shown in Visual Debugger (white backgroundColor)
[![enter image description here][2]][2]
Device running iOS 13 (blue backgroundColor)
[![enter image description here][3]][3]
I've tried the suggestion of applying a `backgroundImage` as suggested in this SO post:
Any guidance or suggestions is greatly appreciated! I've also filed a bug report with Apple, will see if anything comes of that.
[1]:
[2]:
[3]:
I've seen questions that answer how to set the `selectedSegmentTintColor` and such but I'm struggling to set the `backgroundColor` to say `.white`, no matter what I do it always shows up a bit of a gray even though there's no `tintColor` or similar setting applied. Setting the `backgroundColor` to other colors shows the same behavior but its most obvious with white. Adding to the mystery is that while this difference shows up on both iOS 13 simulators and a physical device running iOS 13, the visual debugger (in XCode 11 GM2) does not show this difference!
Here's a couple screenshots showing that even though the `backgroundColor` of the `UISegmentedControl` is set to the same as the `backgroundColor` of the view shown behind it they are slightly different.
Device running iOS 13 (white backgroundColor)
[![enter image description here][1]][1]
Same view/code shown in Visual Debugger (white backgroundColor)
[![enter image description here][2]][2]
Device running iOS 13 (blue backgroundColor)
[![enter image description here][3]][3]
I've tried the suggestion of applying a `backgroundImage` as suggested in this SO post:
[To see links please register here]
but that ends up reverting the style back to how it looked in iOS 12 and you lose the nice animation as well.Any guidance or suggestions is greatly appreciated! I've also filed a bug report with Apple, will see if anything comes of that.
[1]:
[2]:
[3]: