【发布时间】:2018-11-23 15:32:53
【问题描述】:
我正在使用自动布局在滚动视图中设置内容。滚动视图中的对象从上到下固定在前一个对象上,因此它们在彼此之下。我在这些对象下方添加了一个页脚视图。
这里有个问题:当内容很少时,contentView 会小于屏幕高度,因此页脚视图会出现在屏幕中间的某个位置(这是正常行为)。但我想阻止这种情况,并使视图保持在底部的某个位置。
换句话说,我想设置一个双重约束,例如:
Put this view below all the objects in the scrollview
AND
keep this view at a distance of max [some number] of the bottom of the screen
以始终满足两个约束的方式:
- 如果内容的高度大于屏幕,则向下滚动后视图显示在底部
- 如果高度较小,则视图被“固定”到屏幕底部,在内容底部和视图顶部之间留出相对较大的空间
如何使用 AutoLayout 实现这一点?
【问题讨论】:
-
查看我对仅自动布局解决方案的回答。
标签: ios swift autolayout constraints