UIStackView中的重叠视图 [英] Overlapping Views in UIStackView
问题描述
我有一个水平堆栈视图,我添加了子视图(7个单元格)。
堆栈中的每个单元格都有一个超出视图边界的圆形徽章(负面约束)。
运行时,如下所示,每个单元格位于上一个单元格徽章的顶部。我想更改订单,以便徽章完全可见。
尝试使用Z索引但是它没有帮助,因为这些图层在某种程度上不是平坦的,如下面的视图层次结构所示:
有任何想法或建议怎么做?
谢谢。
这不包括通用案例,因为设备可能已在其全局设置中设置了RTL语言。对于通用情况,我想我需要检查界面语义并强制反向我的堆栈视图。
P.S。这是一种破解,所以任何关于如何以不同的方式重新排序子视图的Z顺序的想法将是最受欢迎的!
I have an horizontal stack view that I added arranged sub views to it (7 cells). Each one of the cells in the stack has a circular badge that exceeds the view boundaries (negative constraint). When running, as you can see below, each cell is on top of the badge of the previous cell. I would like to change the order so that the badges will be fully visible.
Tried playing with the Z index but it didn't help as the layers are somehow not flat as you can see in the following view hierarchy:
Any idea or suggestion how to do it?
Thanks.
The documentation for the UIStackView class tells that:
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.
which is exactly what I experienced in the question. To over come my specific case I did the trick of changing the semantic of the view to be RTL as can bee seen here:
This is not covering the a generic case because a device may have been set a RTL language in its global settings. For the generic case I guess I will need to check the interface semantic and force an opposite direction to my stack view.
P.S. It's kind of hack so any ideas about how to reorder the Z-order of subviews in a different way will be most welcome!
这篇关于UIStackView中的重叠视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!