Segmented control Uisegmentedcontrol

Source: Internet
Author: User

Fragment control Uisegmentedcontrol inheritance and Uicontrol

    Uisegmentedcontrol *segmentedcontrol = [[Uisegmentedcontrol alloc] initwithitems:@[@ "All Business", @ "preferential merchant", @ "my"];    Segmentedcontrol.center = Cgpointmake (182,);        The size of each segment is evenly divided by the size of the entire segmentedcontrol, and if Apportionssegmentwidthsbycontent is set to Yes, the size of each segment is allocated according to the content.    segmentedcontrol.apportionssegmentwidthsbycontent = YES;        Sets the currently selected segment subscript    segmentedcontrol.selectedsegmentindex = 1;        Select an instant has effect, then no, restore (not used)    //segmentedcontrol.momentary = YES;        Font color    segmentedcontrol.tintcolor = [Uicolor orangecolor];    Segmentedcontrol.frame = CGRectMake (ten, +, 345, +);        Add an event to Segmentedcontrol    [Segmentedcontrol addtarget:self Action: @selector (Dotapsegmentedcontrol:) forControlEvents: (uicontroleventvaluechanged)];        [Self.view Addsubview:segmentedcontrol];    [Segmentedcontrol release];

  

-(void) Dotapsegmentedcontrol: (Uisegmentedcontrol *) segmentcontrol{    NSLog (@ "O (∩_∩) o haha ~");    Switch (segmentcontrol.selectedsegmentindex) {case        0:            self.view.backgroundColor = [Uicolor redcolor];            break;        Case 1:            self.view.backgroundColor = [Uicolor yellowcolor];            break;        Case 2:            self.view.backgroundColor = [Uicolor bluecolor];            break;                    Default: Break            ;    }}

  

Segmented control 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.