문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top