I have a segmented control. Whenever the view has finished appearing I create a bar button item to hold it and set that as the toolbars item. The problem I'm having is that the segmented control will not fill up the space in the toolbar, even though it is set to have space-filling behaviour.
How can I have a space-filling segmented control in a toolbar in an iOS app?
A segmented control is a linear set of two or more segments, each of which functions as a button. Within a segmented control, all segments are usually equal in width. Like buttons, segments can contain text or images.
First, we need to create our variable:Three variables to customize our view with a default value. Now we need to put our buttons in view but we have an array and this can be unlimited. The best to do this is create a Horizontal Stack View. Stack View makes the subViews with equal spacing without using any constraint.
It sounds like you're trying to get non-standard toolbar behavior out of a UIToolbar. Why not just drop a UIView in there and fill it with a UISegmentedControl in the normal way? Is there some specific functionality of the UIToolbar that you need?
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