UISegmentedControl with square corners UISegmentedControl with square corners ios ios

UISegmentedControl with square corners


To make the corner square use the following code:

segmentContrl.layer.borderColor=*anycolor*.CGColor;segmentContrl.layer.cornerRadius = 0.0;segmentContrl.layer.borderWidth = 1.5f;


One alternative, if "cropping" part of the first and last segment is problematic, may be to crop the entire first and last segment (which you've made dummy unused segments). That way you can still keep a common size for every segment.


Just use the built in customization methods and set a background image for each segment state. This will override the border entirely. If the background images are square, then your segmented control will appear square. Use the following code for each segment state you want to customize.

[segmentedControl setBackgroundImage:[UIImage imageNamed:@"square-background-image-selected"] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];