我有以下设置,我无法正确使用 auto-layout:
Scroll View, which should take the whole screen
|_ Stack View, which should take the whole size of the Scroll View
|_ View 1 with a predefined height of 200
|_ View 2 with a flexible height defined by content, but minimum 300
|_ View 3 with a predefined height of 500
我还尝试了以下内容:
-
滚动视图
-
将 top,bottom,leading 和 trailing 对齐设置为 superview
-
堆栈视图
-
将顶部,底部,前导和尾部对齐设置为 superview(滚动视图)
-
将等宽设置为 superview(滚动视图)
-
将高度设置为 superview(滚动视图),优先级为 250
-
堆栈视图中的 3 个视图
-
为 View1 定义 height = 200,为 View3 定义 height = 500
-
为 View2 定义高度> = 300
我得到:
-
IB 中的错误:View2 的不等约束歧义
-
如果我启动并滚动,我会在顶部和底部获得额外的间距(请参阅模拟器截图中顶部和底部的红色区域)
请看截图:
1 回答
将顶部,底部,前导和尾部对齐更改为SafeArea
因为内容视图总是在 SafeArea 内部。