UIView层次管理(sendSubviewToBack,bringSubviewToFront)
- (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()方法。
文章来源: zzzili.blog.csdn.net,作者:清雨小竹,版权归原作者所有,如需转载,请联系作者。
原文链接:zzzili.blog.csdn.net/article/details/8468590
- 点赞
- 收藏
- 关注作者
评论(0)