问题
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
回答1:
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).
回答2:
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];
来源:https://stackoverflow.com/questions/1507174/uiview-how-do-i-place-a-subview-behind-its-parent-superview