Set Display items for segment
Self.mysegment=[[uisegmentedcontrol alloc]initwithitems:@[@ "Red" @ "blue" @ "green"];
Add Item
[Self.mysegment insertsegmentwithtitle:@ "Yellow" atindex:3 animated:yes];
Add the Default check
Self.mysegment.selectedsegmentindex=1;
Set Location
Self.mysegment.frame=cgrectmake (100, 100, 200, 50);
Add Event
[Self.mysegment addtarget:self Action: @selector (Changea) forcontrolevents:uicontroleventvaluechanged];
[Self.view addSubview:self.mySegment];
Case List
Self.myimage = [[Uiimageview alloc] Initwithframe:cgrectmake (0,60, Self.view.frame.size.width, SELF.VIEW.FRAME.SIZE.HEIGHT-50)];
[Self.view AddSubview:self.myimage];
Text
Self.lblnn=[[uilabel Alloc]initwithframe:cgrectmake (50, 500, 300, 100)];
[Self.lblnn Settextcolor:[uicolor Greencolor];
self.lblnn.numberoflines=5;
Sets the display item for the segment.
Self.mysegment=[[uisegmentedcontrol alloc]initwithitems:@[@ "Peach blossom", @ "Plum blossom", @ "cherry blossom"];
Set Location
Self.mysegment.frame=cgrectmake (100, 20, 200, 30);
Add Event
[Self.mysegment addtarget:self Action: @selector (change) forcontrolevents:uicontroleventvaluechanged];
Add to view
[Self.view addSubview:self.mysegment];
}
-(void) Change
{
int index= (int) Self.mysegment.selectedSegmentIndex;
Switch (index) {
Case 0:
Get Pictures
Self.myimage.image = [UIImage imagenamed:@ "Timg-2.png"];
Add to Parent View
[Self.view AddSubview:self.myimage];
Self.lblnn.text [email protected] "rose family, peach plant." small deciduous trees; leaves narrow-elliptic to lanceolate, 15 cm long, 4 cm wide, apex growing and finely pointed, margin finely toothed, dark green glossy, leaf base with nectar glands. ";
[Self.view AddSubview:self.lblnn];
Break
Case 1:
Get Pictures
Self.myimage.image = [UIImage imagenamed:@ "Timg.png"];
Add to Parent View
[Self.view AddSubview:self.myimage];
Self.lblnn.text [email protected] "Plum, aka Mei, alias: Plum, dried plum, plum, plum, rose family, apricot small trees, sparse shrubs, bark grayish or greenish, smooth; branchlets green, smooth glabrous. Leaf blade ovate or elliptic "";
[Self.view AddSubview:self.lblnn];
Break
Case 2:
Get Pictures
Self.myimage.image = [UIImage imagenamed:@ "12009759_224414328147_2.png"];
Add to Parent View
[Self.view AddSubview:self.myimage];
Self.lblnn.text [email protected] "Cherry blossom (scientific name: Cerasus ssp.): It is a general term for several plants of the genus Rosa, and in the new revision of the Chinese plant records, it refers to" Tokyo Cherry Blossom ", also known as" Japanese cherry blossom ". There are more than 300 kinds of cherry blossoms in the world, there are about 150 species of cherry blossom, there are more than 50 species in China. There are about 40 species of wild species of cherry plants in the world, there are 33 species originating from China.
[Self.view AddSubview:self.lblnn];
Break
Default
Break
}
}
UI Sigment Properties and methods and cases