How Intrinsic Content Size helps me to know my View profoundly!

Sakshi
1 min readMay 1, 2021

--

I wonder why only two constraints are enough for label but not for view in auto layout, though we know the general rule:

Auto Layout to render the scene and size of a view correctly, Auto Layout mechanism must know or able to calculate the :

  1. x position of a view
  2. y position of a view
  3. Width of a view
  4. Height of a view precisely.

So, what is Intrinsic Content Size of View?

From where my label took its width and height?

So some views have a natural size given their current content. A label’s intrinsic content size is based on the amount of text shown and the font used. For example, for our given view we are not forcefully given it height and width.

But didn’t it give us one more question in our mind? What if the available space is lot so smaller/larger than our intrinsic content size?

The answer is the whole new vast topic that is content compression resistance priority and a content hugging priority

Conclusion:

The intrinsic content size help me to reduce my constraint in the view and simplify it.

Hope it help you too!

--

--

Sakshi
Sakshi

Responses (1)