UISegmentedControl相关
NSArray *segmentedArray = [[NSArrayalloc]initWithObjects:@"1",@"2",@"3",@"4",nil];
UISegmentedControl *segmentedControl = [[UISegmentedControlalloc]initWithItems:segmentedArray];
segmentedControl.frame = CGRectMake(20.0,……)
segmentedControl.selectedSegmentIndex = 2;
segmentedControl.tintColor = [UIColor redColor];
segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBordered;
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBezeled;
segmentedControl.momentary = YES;
[segmentedControl setTitle:@"two" forSegmentAtIndex:1];
[segmentedControl setImage:[UIImage imageNamed:@"btn_jyy.png"] forSegmentAtIndex:3];
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"mei.png"] atIndex:2 animated:NO];
[segmentedControl insertSegmentWithTitle:@"insert" atIndex:3 animated:NO];
[segmentedControl removeSegmentAtIndex:0 animated:NO];
[segmentedControl setWidth:70.0 forSegmentAtIndex:2];
[segmentedControl setContentOffset:CGSizeMake(10.0,10.0) forSegmentAtIndex:4];
UIImageView *imageForSegmentAtIndex = [[UIImageViewalloc]initWithImage:[segmentedControl imageForSegmentAtIndex:1]];
imageForSegmentAtIndex.frame = CGRectMake(60.0, 120.0, 30.0, 30.0); ;
UILabel *titleForSegmentAtIndex = [[UILabel alloc]initWithFrame:CGRectMake(100.0, 160.0, 30.0, 30.0)];
titleForSegmentAtIndex.text = [segmentedControl titleForSegmentAtIndex:0];
UILabel *numberOfSegments = [[UILabel alloc]initWithFrame:CGRectMake(140.0, 170.0, 30.0, 30.0)];
numberOfSegments.text = [NSString stringWithFormat:@"%d",segmentedControl.numberOfSegments];
UILabel *widthForSegmentAtIndex = [[UILabel alloc]initWithFrame:CGRectMake(180.0, 210.0, 70.0, 30.0)];
widthForSegmentAtIndex.text = [NSString stringWithFormat:@"%f",[segmentedControl widthForSegmentAtIndex:2]];
[mySegmentedControladdTarget:selfaction:@selector(didClicksegmentedControlAction:)forControlEvents:UIControlEventValueChanged];
oid)didClicksegmentedControlAction:(UISegmentedControl *)Seg{
NSInteger Index = Seg.selectedSegmentIndex;
NSLog(@"Index %i", Index);
switch (Index) {
case 0:
[self selectmyView1];
break;
case 1:
[self selectmyView2];
break;
case 2:
[self selectmyView3];
break;
case 3:
[self selectmyView4];
break;
default:
break;
}