Sometimes we need to segment the page, that is, to group. The base class is Uisegmentedcontrol, and its properties are shown below:
Basically is a few paragraphs, paragraph of the title, each paragraph of the image. Now let's drag a segment, the default is two paragraphs, set its number of segments to 3, to the third paragraph named.
The event of the segment is the ValueChanged event where this segment has been toggled. Now let's do this by dragging a label to the interface and letting the segment switch to show the title of the segment in the label.
Similar to the method in the previous speech, the label is dragged to the controller, and the segment event value changed is dragged to the controller.
Then add the code of the operation to the event:
@IBAction func segchanged (sender:uisegmentedcontrol) { Label1.Text = Sender.titleforsegmentatindex ( Sender.selectedsegmentindex) }
The results are as follows:
Swift UI special training-segmented control segment controls