Is it possible to change the corner radius of UISegmentedControl? I have tried the following approach which we use to change a UIView's corner radius.
self.segmentedControl.layer.cornerRadius = 15.0;
self.segmentedControl.layer.masksToBounds = YES;
This did not work as you can see it only cuts off the UISegmentedControl's corner.
Thanks!
The segmented control is not going to change the way it draws its corners, so it is continuing to draw its corners in its own way and you are then cutting them off. You are not in charge of how a segmented control draws its boundary shape. If you truly don't like the way it's drawn, you'll have to devise your own substitute control from scratch. The closest you can legitimately come to the kind of thing you're trying to do is to set the segmented control's background image.
This is a converted and working code for Swift 4.1 and Xcode 9.3 of Yakiv's post.
Use the following code :
Updated for Swift 3 & Xcode 8.2 compatibility
Embed UISegmentedControl inside UIView and set corner radius for UIView.
Objective-C
Swift
This should work:
You need to specify the border after setting cornerRadius.