The UISegmentedControl does not have an option to do as you have stated. You will have to implement your own custom segmented controller using UIViews, UIButtons, or UILabels, etc.
Change color of outer border for SegmentedControl in Objective-C
-
08-07-2023 - |
Question
I have a Segmented Control object, and I want to change the color of the outer border while preserving the line between the two options. I currently have the code:
self.segmentedControl.tintColor = [UIColor whiteColor]; //sets border and text to white
[self.segmentedControl setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor darkGrayColor]} forState:UIControlStateNormal]; //sets selected segment text to dark grey
However, this code also sets the line between the two options white. Is there any way to change the color of only the outer border, or should I just place two buttons next to each other?
Solution
OTHER TIPS
By this way you can do it:
segControl.tintColor = [UIColor whiteColor];
If you want to change the text color white use below snippet:
[segControl setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateNormal];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow