D. Finna
D. Finna

Reputation: 467

Labels with constrains added to ImageView with aspect ratio

I have an ImageView that are pinned to top, left and right. I want it to increase/decrease height after what device it is viewed on and therefore did not add a specific height or pin it to the bottom, but instead added aspect ratio.

Under the ImageView, I have two labels that will vary in height. One can be a maximum of 4 lines (OVERSKRIFT OVERSKRIFT...) and the other should not have a limit (Label).

I do however see a mistake in the constraints as the image suggests. How can I solve this issue?

enter image description here

Upvotes: 0

Views: 198

Answers (2)

McDonal_11
McDonal_11

Reputation: 4075

  1. ImageView - Top,left,right and AspectRatio [Tick the Constraints to margin]
  2. Label1 - Top,left,right and height and NumberOfLines is 0
  3. Label2 - Top,left,right and height and NumberOfLines is 0

Click, UILabel, in Size Inspector, Give horizontal and vertical as 1000 & 1000 respectively for both Content Hugging Property and Content Compression Resistance Priority.

Click, UILabel's Height Constraints, in Size Inspector, Change its Priority to 750.

Upvotes: 0

Shehata Gamal
Shehata Gamal

Reputation: 100503

1- Remove the bottom most constraint and re add it

2- set content Hugging priority vertical to overskirt label to 1000

Upvotes: 1

Related Questions