Specify Segment Sizes

PDF for offline use
Related Articles:
Related SDKs:

Let us know how you feel about this

Translation Quality


This recipe shows how to create a UISegmentedControl with different sized segments.


To create a UISegementedControl where the segments are different widths:

  • Create and position the control:
var segmentControl = new UISegmentedControl();
segmentControl.Frame = new CGRect(20,20,200,40);
  • Add the segments and select the default:
segmentControl.InsertSegment("Map", 0, false);
segmentControl.InsertSegment("Road", 1, false);
segmentControl.InsertSegment("Satellite", 2, false);
segmentControl.SelectedSegment = 1;
  • Set the sizes for each segment
segmentControl.SetWidth (40f, 0);
segmentControl.SetWidth (80f, 1);
segmentControl.SetWidth (120f, 2);

Additional Information

If the sum of the segment widths is different to the width of the control, the segment widths will override the Frame.Width.

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.