Search code examples
iphoneobjective-cuiimageviewuilabeluielement

How to stack/z-position multiple UIElements (uilabel, uiimageview, etc) on top of each other?


I've got several UI elements on my screen (programmatically) and am in need of an efficient way to give each subview a z-index setting, so I can stack certain elements over others.

Does anyone have a solution to this?


Solution

  • The plain -addSubview: method will add the new view on top of its siblings.

    There are also a bunch of methods like bringSubviewToFront:, insertSubview:belowSubview:, etc. that you can use to manipulate the ordering, listed under "Managing the View Hierarchy" in the UIView Reference