如何使用 IOS UIstackview distribution proportional 将 iphone 屏幕分成四个不同的 UIView(相对于屏幕高度)的比例

How to divide the iphone screen into a proportion of four different UIView( respect to screen height) using IOS UIstackview distribution proportional

如何将 iphone 屏幕高度分成 4 个不同的 UIView,高度分别为 0.2 * screenHeight、0.3 * screenHeight、0.3 * screenHeight 和 0.2 * screenHeight。为此,我使用 stackview,顶部、底部、尾部和前导的约束为 0,分布是成比例的。但是当我为视图设置相同的高度并将乘数设置为所需时,如上所述,它给我错误提示未设置 UIViews y 轴。我该如何解决 this is screenshot

error screenshot

将 stackview 顶部、左侧、底部、右侧约束设置为 0。

将 stackview 分布设置为填充。

将堆栈视图间距设置为 5

对于高度为 0.2 的视图 1,设置波纹管约束

  • 与堆栈视图等高;常量:-3.75;乘数:0.2
  • 与 view4 等高

对于高度为 0.3 的视图 2,设置波纹管约束

  • 与堆栈视图等高;常量:-3.75;乘数:0.3

我们使用了 15 个像素的间距。所以我们需要在所有 4 个视图中平均划分这 15 个像素,即 15/4 = 3.75

波纹管是 link 的解决方案

https://www.dropbox.com/s/nudo593mjhsxmn4/viksitIOSApp-master_Solved.zip?dl=0