Вопрос

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