Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoLayout Tips: UIScrollView子视图宽度怎么确定 #31

Open
ghost opened this issue May 13, 2017 · 0 comments
Open

AutoLayout Tips: UIScrollView子视图宽度怎么确定 #31

ghost opened this issue May 13, 2017 · 0 comments

Comments

@ghost
Copy link

ghost commented May 13, 2017

正常来说,只需要上边和左边就能确定 UILabel 的位置,但右边的约束的作用实际是“撑宽”UIScrollView,这时错误就只有一个了:
很明显,UIScrollView 可以确定其 contentView 的宽度了,因为 UILabel 的宽度固定,它的左边到 UIScrollView 的左边固定,它的右边到 UIScrollView 的右边固定,于是 AutoLayout 系统可以通过这些约束“猜出” UIScrollView 的 contentView 的宽度。

引用了文章中的一段话。看到这里我有个疑问,有什么好的办法能使UIScrollView子视图的label宽度左右两边保持和屏幕等距呢(比如说左右各8)。我能想到的是代码加上layoutConstraint。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants