Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying z-order (sendSubviewToBack, etc.) on UIStackView

According to the Apple docs:

The order of the subviews array defines the Z-order of the subviews. If the views overlap, subviews with a lower index appear behind subviews with a higher index.

I can see that this is the case, as I am trying to have its arrangedSubviews manually reordered using sendSubviewToBack, which is having no effect. How can I adjust the z-order of the arrangedSubviews in a UIStackView?

like image 493
Connor Neville Avatar asked Aug 08 '16 13:08

Connor Neville


People also ask

What is UIStackView in Swift?

A streamlined interface for laying out a collection of views in either a column or a row.

What's a UIStackView did you use it?

UIStackView is useful when you need to repeat same views multiple times like in Sing up view. We use many textfields and manually set constraints between each textfields. But if you put all textfields in stack view then you just need to set required constraints of stackview only and not textfields.

How do I use Stackview?

Xcode provides two ways to use stack view: You can drag a Stack View (horizontal / vertical) from the Object library, and put it right into the storyboard. You then drag and drop view objects such as labels, buttons, image views into the stack view. Alternatively, you can use the Stack option in the auto layout bar.


1 Answers

Use this!

yourArrangedSubview.layer.zPosition = xxx

like image 126
Michael Avatar answered Nov 21 '22 16:11

Michael