简体   繁体   中英

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];

it is working.

Let me try to explain you this. Suppose you are having a ViewController containing its own UIView. Then you have certain UIViews in it like view1, view2. view2 is infront of view1. you want to bring view1 infront of 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.

if you want to send view1 back. 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.

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