StackOverflower
StackOverflower

Reputation: 5761

How to avoid UILabel to increase height on this scenario?

I have the following control hierarchy

Scroll View
|__ Content View
    |__ View  (fix height)
    |__ Label (variable content)
    |__ Table (fix height)
    |__ View  (only an anchor for scroll view, no other usage)

Last view is only there to force the scroll actually scroll when necessary (setting bottom space to container to 0 on this view). Without any control setting distance to bottom, I see no scroll.

I have height constrains over 1st view and Table. My problem is that when sum of all heights < screen height, it increases the size of the label to honor last view constraint of bottom space = 0.

I don't want the label to increase the size but the latest view. I tried everything

Nothing worked, I still see the label taking more space than required.

How to avoid label to avoid taking more space than necessary while still honoring the bottom distance to 0 for the view. I'm willing to remove the latest view if there is other way to force scroll view to actually show scroll bar when necesary.

Upvotes: 0

Views: 250

Answers (1)

beyowulf
beyowulf

Reputation: 15331

Click on your label in IB, then click on the size inspector pane, find the horizontal and vertical content hugging priority and increase both. It is low by default you probably want it on high to prevent the layout engine from increasing its size and instead "hug" its intrinsic size.

content hugging priority

Upvotes: 1

Related Questions