在Navigation Bar上添加UISegmentedControl

UISegmentedControl *segCtr;
segCtr = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"1", @"2", @"3", @"4", nil]];
segCtr.tintColor = [UIColor blackColor];
[segCtr addTarget:self action:@selector(showSegment) forControlEvents:UIControlEventValueChanged];
self.navigationItem.titleView = segCtr;
[segCtr release];
 

你可能感兴趣的:(ios,iPhone,navigation bar)