rkade93 rkade93 - 9 months ago 68
Objective-C Question

Change color of outer border for SegmentedControl in Objective-C

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?

Answer Source

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.