Search code examples
iosautolayout

iOS - Can AutoLayout make constraint like view0.height = view1.height + view2.height?


I want make a constraint like view0.height = view1.height + view2.height. And when view1.height or view2.height changed, view0.height will auto changed.

It's passible in iOS AutoLayout?


Solution

  • Yes, it is possible if view0 contains both view1 and view2, then you just need to provide proper constraints. Like this:

    view0's constraints

    view1's constraints

    view2's constraints