dugla
dugla

Reputation: 12954

UIView. How do I place a subview behind it's parent superview

I'm doing a bit of UIView wrangling and am stuck. It is straightforward changing the "z" order of sibling subviews. [mySuperview sendSubviewToBack:mySubview] places mySubview behind all it's siblings.

But how do I place a subview behind it's parent?

Thanks, Doug

Upvotes: 4

Views: 7512

Answers (2)

You may want to put both into a container view, so that you can properly place one behind the other without affecting a superview not really meant to hold arbitrary views (although that will probably work just fine).

Upvotes: 2

Nick Bedford
Nick Bedford

Reputation: 4445

You can't as far as I know. You'll have to remove it from the parent then add it to the parent's parent's subviews.

UIView *parent = view.superview;
[view removeFromSuperview];

/* Adjust frame to realign under parent view */

[parent.superview addSubview:view];

Upvotes: 3

Related Questions