4

enter image description here

1) View A , view B , View C height & width are equal

2) View A height depends on Label1 & Label2 height

3) View B height depends on Label3

4) View c height depends on Label4

5) I want to take max height from View A, View B & View C but all are equal

6) View X heights depend on max of (View A,View B & View C)

How to achieve this through auto-layout?

Thanks in advance

user2526811
  • 1,233
  • 4
  • 20
  • 54

1 Answers1

2

It can be done easily in the Xib or storyboard. Refer to the Screen shot of the constraints created.

Layout With Constraints

V1 --> First View

V2 --> Second View

V3 --> Third View

V1L1 --> First View's First Label

V1L2 --> First View's Second Label

V2L1 --> Second View's First Label

V3L1 --> Third View's First Label

The first View is Having the width constraint of 180 and all the views(V1, V2, V3) are having equal width and equal height constraints.

All the Labels Lines count is set to zero in the attribute inspector, This enables the label height increase as text of the label is more.

The height of V1, V2 and V3 is determined by the content of the labels.

Views height increases based on the labels content and all the view are given equal heights , Hence the Content view height will be the height of the max(V1.height, V2.height, V3.height). Also V1.height = V2.height = V3.height = max(V1.height, V2.height, V3.height)

Below is at the clear image of constraints.

Constraints top image Constraints bottom image

Yatheesha
  • 10,412
  • 5
  • 42
  • 45