Glance here ... http://stackoverflow.com/a/34736594/294884
in iOS the order in which you put sibling views, in the Inspector in Storyboard, of course becomes their z-order.
I was amazed to learn that this does not seem to apply to any such views that are container views.
To test, just make a scene with a few sibling views; a couple of them are container views. Run. Change something innocent in the class of the container view controllers (say, add a ViewDidLoad, constraint, or a print statement) and try again. The container view views are randomly moved to the top.
I find the only work around is you have to manually put them in order, in viewWillAppear, which is nuts.
1) could it be I've just screwed something up - maybe there's a setting ("respect storyboard order even for container views")
2) I've been scratching my head trying to figure out how to "automate" the workaround fix. You'd need to read the order of all views from the storyboard as it's loaded? And then "fix" it at viewWillAppear time. I'm not sure though.
3) could there perhaps be some trick .. in prepareForSegue say? .. to force them to be in the as-seen-in-storyboard sibling order?!
What if you put each container view inside an ordinary
UIView, with all of the container view's edges pinned to the ordinary
UIView? I bet you 5 bucks that fixes it.