Swift UI special training-segmented control segment controls

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.