I just added a UILabel
named label1
to my UIView
in Interface Builder and I want to put it behind an other UILabel
named label2
.
But label2
is behind label1
and I dont know how to change the order.
What I want is that if label2
is hidden, label1
would be visible behind it.
How to add a view below another in Swift:
insertSubview(label1, belowSubview: label2)
How to change view stacking in Interface Builder (main.storyboard):
Just drag your label1 view above label2 in the document outline (left panel on IB)
If your document outline is not open, click this button when you're in the Interface Builder
The stacking order of your elements is read from the top down, unlike photoshop or similar programs, where the bottom of the list is the bottom layer. In the document outline, you can think of it like a reverse order. The items at the top of the list are at the bottom of the displayed views.