经过几个小时的尝试寻找解决方案,以及尝试和失败自己,我决定在这里问。
如下图所示,我有15个金字塔形状的图像视图,我想设置约束。
我试过:
结果总是图像视图超出范围或类似问题。 (Clip to Bounds为真)
任何人都有解决方案或建议吗?
答案 0 :(得分:2)
try putting them all in stack views then putting all those stack views inside a stack view and putting constraints on that
like this take a look at the view hierarchy on the left
to get the spacing i achieved just adjust the spacing on the right inside the attributes inspector
and its even able to have constraints on the highest stack view
all the errors go away once you add constraints to the top stack view
like shown here
答案 1 :(得分:0)
将所有图像视图嵌入到UIView中。
在该视图中设置顶部,底部,前导和尾随约束(顶部图像到superview等)。
在容器中水平和垂直对齐UIView。
您可能还想为UIView设置宽度,但我会考虑您想要的最终结果。