Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to keep a uiview above other views

I have two views (UIView) set-up: parent and child view. The child view is displayed on top of the parent view, as desired. However I need to add subviews now that I would like to be displayed below the child view, but above the parent view. What is an easy way of keeping the first child view on top while adding new subviews? I would like to keep the newly added subviews display order match insertion order.

like image 219
andrewz Avatar asked Mar 13 '11 09:03

andrewz


1 Answers

Use any of the following UIView methods to control depth.

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

This is taken from the View Programming Guide docs in the View Hierarchies and Subview Management section,

Each superview stores its subviews in an ordered array and the order in that array also affects the visibility of each subview. If two sibling subviews overlap each other, the one that was added last (or was moved to the end of the subview array) appears on top of the other.
like image 130
Anurag Avatar answered Sep 30 '22 13:09

Anurag