- (void)viewDidLoad {
[super viewDidLoad];
UILabel *labelA = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 43)];
labelA.lineBreakMode = UILineBreakModeWordWrap;
labelA.numberOfLines = 0;
[labelA setTextAlignment:UITextAlignmentCenter];
[labelA setBackgroundColor:[UIColor clearColor]];
labelA.text = @"ABCDEFGHIJ";
... ...
UISegmentedControl *mySegment = [[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:@" ",@" ",@" ",nil]];
[mySegment setFrame:CGRectMake(10, 0, 300, 43)];
[mySegment setSelectedSegmentIndex:0];
[self.view addSubview:mySegment];
[self.view addSubview:labelA];
[self.view sendSubviewToBack:mySegment];
... ...
[mySegment release];
[labelA release];
... ...
}
附:
将一个UIView显示在最前面只需要调用其父视图的 bringSubviewToFront()方法。
将一个UIView层推送到背后只需要调用其父视图的 sendSubviewToBack()方法。