Change the border width of a UISegmentedControl in iOS 8

How to change the border width UISegmentedControlin iOS 8? Currently the border width is 2px and I would like to set it to 1px. Setting the border width of CALayer does not work. I can't seem to find anything about this.

Thanks in advance for your help!

+4
source share
2 answers

I suggest you use custom separator images depending on your needs:

[mySegmentedControl setDividerImage:image1 forLeftSegmentState:UIControlStateNormal                   rightSegmentState:UIControlStateNormal barMetrics:barMetrics];
[mySegmentedControl setDividerImage:image2 forLeftSegmentState:UIControlStateSelected                   rightSegmentState:UIControlStateNormal barMetrics:barMetrics];
[mySegmentedControl setDividerImage:image3 forLeftSegmentState:UIControlStateNormal                   rightSegmentState:UIControlStateSelected barMetrics:barMetrics];

Check out the documentation here https://developer.apple.com/library/ios/documentation/userexperience/conceptual/UIKitUICatalog/UISegmentedControl.html

+2
source

It works with iOS 8.1

   _segmentedControl.layer.borderWidth = 2;
+3
source

All Articles