A summary of the usage of ios--ui articles--uisegmentedcontrol

Source: Internet
Author: User

1  //first method of Creation2Uisegmentedcontrol *seg = [[Uisegmentedcontrol alloc]initwithitems:@[@"1",@"2",@"3"]];3Seg.frame = CGRectMake ( +, -, -, -);4 5[Seg insertsegmentwithimage:[uiimage imagenamed:@"Picture name"] Atindex:4Animated:yes];//set a picture for a paragraph (the picture is transparent with a border to be fully displayed, other pictures can not be fully displayed)6UIImage *image = [seg Imageforsegmentatindex:2];//get a picture of a paragraph7NSLog (@"Image:%@", image);8NSString *str = [seg Titleforsegmentatindex:1];//get the title of a paragraph9NSLog (@ "The first few:%zi", Segment.selectedsegmentindex);//Get the number of the current clickTenNSLog (@"title:%@", str); One[Seg SetWidth: -Forsegmentatindex:1];//set the width of a paragraph A[Seg Setenabled:yes];//sets whether the whole is activated; -[Seg Setenabled:yes Forsegmentatindex:2];//set whether a segment is active -Seg.selectedsegmentindex =1;//set a segment as the default check theNSLog (@"%zi", Seg.selectedsegmentindex);//gets the currently selected segment; -Seg.tintcolor = [Uicolor Purplecolor];//set border and selected color; -[Seg setbackgroundimage:[uiimage imagenamed:@"Picture name"] Forstate:uicontrolstatenormal Barmetrics:uibarmetricsdefault];//set the overall background picture -  +     //Binding Listener Events - [SEG addtarget:self Action: @selector (method Name:) forcontrolevents:uicontroleventvaluechanged]; + [Self.view addsubview:seg]; A  at     //second method of creation -Uisegmentedcontrol *SEG2 = [[Uisegmentedcontrol alloc]initwithframe:cgrectmake ( +, -, -, -)]; -[SEG2 Insertsegmentwithtitle:@"1"Atindex:1Animated:yes]; -[SEG2 Insertsegmentwithtitle:@"2"Atindex:2Animated:yes]; -[SEG2 Removesegmentatindex:1Animated:yes];//Remove a segment -NSLog (@"%zi", seg2.numberofsegments);//get number of segments in [Self.view ADDSUBVIEW:SEG2]; -  to } +  --(void) Myswitch the { *Uiswitch *SWI = (Uiswitch *) [Self.view Viewwithtag:1]; $NSLog (@"%d", Swi.ison);Panax Notoginseng  -}

A summary of the usage of ios--ui articles--uisegmentedcontrol

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.