Instance Property

selectedSegmentIndex

The index number identifying the selected segment (that is, the last segment touched).

Declaration

var selectedSegmentIndex: Int { get set }

Discussion

The default value is noSegment (no segment selected) until the user touches a segment. Set this property to -1 to turn off the current selection. UISegmentedControl ignores this property when the control is in momentary mode. When the user touches a segment to change the selection, the control event valueChanged is generated; if the segmented control is set up to respond to this control event, it sends a action message to its target.

See Also

Managing Segments

func insertSegment(with: UIImage?, at: Int, animated: Bool)

Inserts a segment at a specified position in the receiver and gives it an image as content.

func insertSegment(withTitle: String?, at: Int, animated: Bool)

Inserts a segment at a specific position in the receiver and gives it a title as content.

var numberOfSegments: Int

Returns the number of segments the receiver has.

func removeAllSegments()

Removes all segments of the receiver

func removeSegment(at: Int, animated: Bool)

Removes the specified segment from the receiver, optionally animating the transition.