How to save uiview over other views

I have two views (UIView): parent and child. The child view is displayed at the top of the parent view as desired. However, I need to add subviews now that I would like to appear below the child view, but above the parent view. What is an easy way to keep your child’s first view from above by adding new subtitles? I would like to keep the newly added display order display order display order.

+6
iphone uiview subview
source share
2 answers

To control the depth, use any of the following UIView .

 – bringSubviewToFront: – sendSubviewToBack: – insertSubview:atIndex: – insertSubview:aboveSubview: – insertSubview:belowSubview: 

This is taken from the View docs programming guide in the "View hierarchy" and "View control" sections.

Each supervisor stores its children in an ordered array, and the order in that array also affects the visibility of each subset. If two subordinates of each other are matched to each other, then the one that was added last (or was moved to the end of the subview array) is displayed on top of the other.
+10
source share

I would suggest creating a wrapper method for addSubview . Something like that:

 - (void)insertSubviewBetweenParentAndChild:(UIView *)newChild { [self insertSubview:newChild aboveSubview:parentView]; } 
+1
source share

All Articles