Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
id title brief article sdk
735DF15C-218B-EC0F-3663-DCFF372CE93A
Specify Segment Sizes
This recipe shows how to create a UISegmentedControl with different sized segments.

Recipe

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.