繁体   English   中英

与scrollView相关的Autolayout问题

[英]Autolayout issue related to scrollView

我已经实现了ScrollView。
我想在视图之间切换。
因为它是如此简单的UI东西,我只需要一个Controller并使用hidden属性在两个视图之间切换。 此外,我想定位一些标签和视图。 但是我无法居中,他们位于右侧太远。 我认为我的约束是正确的。 你知道如何解决这个问题吗?

在此输入图像描述在此输入图像描述

根据你的布局,我尝试创建类似的布局。

您需要做的是将Container View添加为UIScrollView的SubView。

滚动视图的约束:

You need to set top,reading,trailing and Height constraints.

容器视图的约束:

You need to set leading,top,trailing and bottom constraints.
You need to set _Height Equally_ to scroll View.
You need to set _Width Equally_ to View.

标签的约束:

1.)标签2约束:

You need to set **Center Horizontally and center Vertically**.

2.)标签1约束:

You need to set **Leading space**.

// I’ve set leading space: 10
You also need to set center Y to label 2.

3.)标签3约束:

You need to set **Trailing space**.

// I’ve set leading space: 10
You also need to set center Y to label 2.

图像视图的约束:

You need to set height,width and Vertical Space Constraints.
you also need to set center Horizontally to View.

在此输入图像描述

希望这可以帮助您解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM