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