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

Latest commit

 

History

History

configure_segments_(uisegmentedcontrol)

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
id title brief sdk
13B08892-8DDC-CDDE-63A1-9994E1569249
Configure Segments (UISegmentedControl)
This recipe shows how to create a UISegmentedControl.

Recipe

ℹ️ Note: On iOS 7 and above, the UISegmentedControl styling has been deprecated.

To create a UISegementedControl:

  1. Create and position the control:
var segmentControl = new UISegmentedControl();
segmentControl.Frame = new CGRect(20,20,280,40);
  1. Add the segments and select the default:
segmentControl.InsertSegment("One", 0, false);
segmentControl.InsertSegment("Two", 1, false);
segmentControl.SelectedSegment = 1;
  1. Optionally handle the ValueChanged event:
segmentControl.ValueChanged += (sender, e) => {
    var selectedSegmentId = (sender as UISegmentedControl).SelectedSegment;
    // do something with selectedSegmentId
};

Additional Information

You can create a UISegmentedControl in Xcode by dragging one to the design surface and setting the Segment count and properties in the Attributes Inspector.