UIView层次管理(sendSubviewToBack,bringSubviewToFront)

[self.view addSubview:mySegment]; 
[self.view addSubview:labelA]; 
[self.view sendSubviewToBack:mySegment];

将一个UIView显示在最前面只需要调用其父视图的bringSubviewToFront()方法。

将一个UIView层推送到背后只需要调用其父视图的sendSubviewToBack()方法。

1.[self.view bringSubviewToFront:view2];
将view2放置到最顶层,index自动管理。

2.[self.view bringSubviewToFront:view2];
将view2放置到最底层,index自动管理。

3.[self.view addSubview:view2];
将view2加到当前视图的上一层,index在上一层的基础上自动+1

[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
改变view层次,手动管理index

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。