I'm setting colors for my segmented control like this:
segmentedControl.backgroundColor = .gray
segmentedControl.selectedSegmentTintColor = .red
let textAttrs: [NSAttributedString.Key : Any] = [
.foregroundColor: UIColor.white
]
segmentedControl.setTitleTextAttributes(textAttrs, for: .normal)
It works well, but when user long taps on it (with large fonts enabled in Settings), I get the following:

As you can see, the text is unreadable. Is there any way to set background/tint colors for the accessibility view?
The best solution I found is to set a background color for the text in title attributes like this:
let textAttrs: [NSAttributedString.Key : Any] = [
.foregroundColor: UIColor.white,
.backgroundColor: segmentedControl.backgroundColor!
]
segmentedControl.setTitleTextAttributes(textAttrs, for: .normal)
let textAttrsSelected: [NSAttributedString.Key : Any] = [
.foregroundColor: UIColor.white,
.backgroundColor: segmentedControl.selectedSegmentTintColor!
]
segmentedControl.setTitleTextAttributes(textAttrsSelected, for: .selected)
The result is better (at least the text is readable), but still it doesn't look good:
Ideally I'd like the accessibility mode view to have the same background color and tint color for selected item as in the main view.


