Is there a way to completely remove the line separating the two segments in a UISegmentedControl?
Setting the segmentedControlStyle
is not helping.
@naveed's and @Jon Setting's answers saved my day!
But as a bit of a perfectionist, i was frustrated to find out that this code also leaves holes in the outer border of the control:
So I added a few lines of code to get rid of those and make it look neat:
The complete code for this would be
CGFloat h = self.segControlOut.frame.size.height;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, h), NO, 0.0);
// draw the missing dots with the control border color
[self.segControlOut.tintColor set];
UIRectFrame( CGRectMake(0, -1, 1, 2.5) );
UIRectFrame( CGRectMake(0, h-1.5, 1, 2.5) );
UIImage *blank = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.segControlOut setDividerImage:blank
forLeftSegmentState:UIControlStateNormal
rightSegmentState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];