Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have a space-filling segmented control in the toolbar in an iOS app?

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?

like image 399
Molossus Spondee Avatar asked May 02 '12 01:05

Molossus Spondee


People also ask

What is segmented control in iOS?

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.

How do I create a custom segmented control in Swift?

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.


1 Answers

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?

like image 94
jemmons Avatar answered Sep 21 '22 18:09

jemmons