可以子视图,支持自动布局自动调整自己的SuperView? [英] Can subviews resize their superview automatically with auto layout?

查看:120
本文介绍了可以子视图,支持自动布局自动调整自己的SuperView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你有上没有约束的视图,该视图与左,右,上和同样大小的底部约束的子视图,如果子视图的尺寸增加是有可能为上海华的大小自动增加至满足这些约束条件?

If you have a view with no constraints on it, and that view has a subview with left, right, top and bottom constraints of equal size, if the subview's size is increased is it possible for the superview's size to automatically increase to accommodate these constraints?

感谢。

推荐答案

是的,你能做到这一点,它可以没有任何code或子类来完成。例如,如果你有嵌入在图(numberOfLines = 0)一标签,它具有限制向上海华,以及一个宽度约束,标签的所有的侧面,如果它的父将垂直展开放一个大字符串中的标签。在上海华应该还是需要有一定的限制,比如一到它的父的顶部和左侧,但没有大小限制。

Yes, you can do that, and it can be done without any code or subclassing. For instance, if you have a label embedded in a view (with numberOfLines = 0), and it has constraints to to all the sides of the superview, as well as a width constraint, the label, and its superview will expand vertically if you put a large string in the label. The superview should still need to have some constraints, like one to the top and left side of its superview, but no size constraints.

这篇关于可以子视图,支持自动布局自动调整自己的SuperView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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