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?
A streamlined interface for laying out a collection of views in either a column or a row.
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.
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.
Use this!
yourArrangedSubview.layer.zPosition = xxx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With