Step-by-step learning the properties of the iOS (Uisegmentedcontrol) segmented control

Source: Internet
Author: User
Tags set background

Create a Segment button

Uisegmentedcontrol *segment = [[Uisegmentedcontrol alloc] Initwithframe:cgrectmake (100, 200, 100, 50)];

Set the width of the item

Uicolor *mytint = [[Uicolor alloc] initwithred:0.66 green:1.0 blue:0.77 alpha:1.0];

Segment.tintcolor = Mytint;

Add a Fragment

[Segment insertsegmentwithtitle:@ "First" atindex:0 Animated:yes];

[Segment insertsegmentwithtitle:@ "the Atindex:2 Animated:yes];

[Segment Insertsegmentwithimage:[uiimage imagenamed:@ "Ondemo"] atindex:3 Animated:yes];

Delete Segment

[Segment Removesegmentatindex:2 animated:yes];//Delete a fragment

[Segment removeallsegments];//Delete all clips

Fragment title

[Segment Setimage:[uiimage imagenamed:@ "Statrdemo"] forsegmentatindex:1];

Select Segments

Segment.momentary = YES;

Specify the selected button

Segment.selectedsegmentindex = 1;

Set Background color

Segment.backgroundcolor = [Uicolor Puoplecolor];

Add to navigation bar, no navigation bar without any effect

Self.navigationItem.titleView = segment;

Read the value of the control's fragment button

int x= Segment.selectedsegmentindex;

Add Event

[Segment Addtarget:self Action: @selector (Selectedd:) forcontrolevents:uicontroleventeditingchanged];

[Self.view addsubview:segment];

Step-by-step learning the properties of the iOS (Uisegmentedcontrol) segmented control

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.