9

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?

Connor Neville
  • 7,291
  • 4
  • 28
  • 44

1 Answers1

11

Use this!

yourArrangedSubview.layer.zPosition = xxx

Michael
  • 9,639
  • 3
  • 64
  • 69
  • This seems to work, but it seems to be undocumented behavior. On which iOS versions will work? will it break in the future? I wouldn't rely on this except for cosmetic changes that you are OK might break at some point. – José Manuel Sánchez Jan 10 '22 at 15:14
  • Hard to say. I wrote this answer several years ago. Seems to still be working nicely. I would imagine as long as UIStackView and UIView don't change too dramatically, this should work. – Michael Jan 10 '22 at 20:16