簡體   English   中英

超級視圖將子視圖置於最前面是行不通的。 怎么做?

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

我使用許多功能將子視圖帶入超級視圖,但它不起作用。 例如

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

不工作

但是[superview sendSubviewToBack:suberview];

這是工作。

讓我嘗試向您解釋。 假設您有一個包含其自己的UIView的ViewController。 然后,其中具有某些UIView,例如view1,view2。 view2位於view1的前面。 您想將view1置於view2的前面。 您需要做的就是調用此方法。

[self.view bringSubviewToFront:view1]; self.view是父視圖,view1是視圖層次結構中要在其前面顯示的視圖。

如果您想發回view1。 您可以通過使用

[self.view sendSubviewToBack:view1];  

它將view1發送到后面,view2將顯示在前面。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM