简体   繁体   English

超级视图将子视图置于最前面是行不通的。 怎么做?

[英]It's not working that superview bring the subview to front. how to do it?

I use many function to bring subview to superview but it is not working. 我使用许多功能将子视图带入超级视图,但它不起作用。 for example 例如

[superview bringSubviewToFront:suberview];
[superview insertSubview:suberview belowSubview:someView];
[superview insertSubview:suberview aboveSubview:someView];

are not working 不工作

but [superview sendSubviewToBack:suberview]; 但是[superview sendSubviewToBack:suberview];

it is working. 这是工作。

Let me try to explain you this. 让我尝试向您解释。 Suppose you are having a ViewController containing its own UIView. 假设您有一个包含其自己的UIView的ViewController。 Then you have certain UIViews in it like view1, view2. 然后,其中具有某些UIView,例如view1,view2。 view2 is infront of view1. view2位于view1的前面。 you want to bring view1 infront of view2. 您想将view1置于view2的前面。 All you need to do is call this method. 您需要做的就是调用此方法。

[self.view bringSubviewToFront:view1]; self.view is parent view and view1 is the view in views hierarchy whom you want to bring in the front. self.view是父视图,view1是视图层次结构中要在其前面显示的视图。

if you want to send view1 back. 如果您想发回view1。 You can achieve this by using 您可以通过使用

[self.view sendSubviewToBack:view1];  

it will send view1 to the back and view2 will be shown at the front. 它将view1发送到后面,view2将显示在前面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM