如果内容不够大,如何使按钮停留在滚动视图的底部? [英] How to make button stick to bottom of scroll view if the content isn't large enough?

查看:73
本文介绍了如果内容不够大,如何使按钮停留在滚动视图的底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果按钮和标签之间的等式约束为20,并且标签中包含大量文本,则会发生这种情况:

This is what happens if there is an equality constraint of 20 between the button and the label and the label has a lot of text:

如果文本很小,会发生以下情况:

This is what happens if the text is small:

如您所见,按钮位于标签下方20的距离处.当标签的文本不够大时,我希望它位于视图的底部.

As you can see, the button is placed at a distance of 20 under the label. I want it to be at the bottom of the view when the label's text isn't big enough.

我尝试将等式约束更改为>= 20约束,但是现在,IB表示滚动视图需要Y约束.

I tried changind the equality constraint to a >= 20 constraint but now, IB says the scroll view needs constraint for Y.

这些是我的限制条件

推荐答案

我解决此问题的方法是将按钮与容器视图放置在视图层次结构中的同一级别,以使其浮在视图上并且不受影响通过滚动.

The way I solved this was to place the button at the same level in the view hierarchy as the container view so that it floats over the view and is not impacted by scrolling.

在我的按钮下方的图像中,该按钮位于左上角,但是无论tableView如何滚动,该位置均保持不变.请注意,按钮在层次结构中与tableView处于同一级别.

In the image below my button is in the top left corner, but remains fixed in place regardless of how the tableView is scrolled. Notice how the button is at the same level in the hierarchy as the tableView.

这篇关于如果内容不够大,如何使按钮停留在滚动视图的底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆