Is there a way of get rid of UISegmentedControl's rounded corners or it is the default behavior?
There's something really easy that you can do to rid yourself of the rounded junk on the UISegmentedControl ... change the style to "7". I'm not joking. I just figured this out:
// Magic number ... (it's cheating, but it works)
mySegmentedBar.segmentedControlStyle = 7;
This is the same control style they use in the UISearchBar's scope bar, like this:
But if someone only wants the scope bar, without the search, they're usually stuck with UISegmentedControl junk like this (with rounded corners):
Or worse, this...
Thankfully, by switching to bar style "7", we get the exact look of the stop bar, without all the subclassing and drawRect hackery:
No, there is no API that gives you control over the layout of the segments.
You could probably try looking into the UISegmentedControl's view.subviews and try to change them according to your needs. But from personal experience I would not advice that. If Apple changed their order in the future your app will probably crash. The easiest thing to do is to create custom UIButtons that behave as toggle-buttons and control them like a UISegmentedControls (for toggle-buttons see How to use a UIButton as a toggle switch).
If you wanted a different look you could just subclass it and do your own drawing in -drawRect:
. See the Quartz 2D Programming Guide for reference on drawing with Quartz/Core Graphics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With