简体   繁体   中英

How to bring subView to top from superview of its superview

I have a view hierarchy as view 1 --> view 2 --> view 3. So, view 3 is subview of view 2 which is a subview of view 1. Now, from view 1, I want to bring view 3 to front without bringing view 2 to front. I cannot add view 3 in window due to relative positioning within view 2.

Any idea?

不,你不能。不应该从视图2中删除view3并添加到视图1,然后使用bringSubviewToFront:方法将其放到前面。

请参阅将视图移动到新的超级视图而不闪烁 ,您可以将相对帧转换为窗口,然后将视图添加到窗口,这将使视图3保持在其原始帧上

你可以尝试这个代码..

[self.view bringSubviewToFront:yourview];

You can not access view3 directly without accessing view2.

Try this :

[view2 bringSubviewToFront:view3];
[view1 bringSubviewToFront:view2];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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