0

Let's assume I have 4 views, 3 in a row and 1 in another row. The ones at the first row have dynamic height and we have no idea how tall they are.

I want to achieve the result from this image:

enter image description here

Basically I want to set View 4's top to bottom of highest view in first row. How can I achieve this?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
The Cook
  • 1,403
  • 3
  • 17
  • 33

2 Answers2

1

Use greaterThanOrEqualTo:

view4.topAnchor.constraint(greaterThanOrEqualTo: view1.bottomAnchor, constant: 10).isActive = true
view4.topAnchor.constraint(greaterThanOrEqualTo: view2.bottomAnchor, constant: 10).isActive = true
view4.topAnchor.constraint(greaterThanOrEqualTo: view3.bottomAnchor, constant: 10).isActive = true
0

Put View1, View2 and View3 inside UIStackView (or regular UIView), and then add constraint between bottom of this new view and top of View4

Vasilii Muravev
  • 3,063
  • 17
  • 45