My UISegmentControl
has no borders and segment separators. I want to place a line below the selected segment. I tried doing this :
CALayer *bottomLayer = [CALayer layer];
bottomLayer.borderColor = [UIColor blackColor].CGColor;
bottomLayer.borderWidth = 3;
// Calculating frame
CGFloat width = segment.frame.size.width/segment.numberOfSegments;
CGFloat x = 0;
CGFloat y = segment.frame.size.height - 5;
bottomLayer.frame = CGRectMake(x, y,width, 2);
[bottomLayer setName:@"bottom"];
// Adding selection to segment
[segment.layer addSublayer:bottomLayer];
This puts a line when I tap the segment. But when I release the tap, line is no more seen. I am using UIControlEventValueChanged
as the controlEvent.
How may I achieve this without using third party.