可以子视图,支持自动布局自动调整自己的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.