Hi All,
We have properties to set content according to content length and device screen size which help us to manage user interface of an application. Content hugging priority and content compression resistance priority helps you to maintain User interface of application.
Let have an example : Place a button with top , leading , trailing and central horizontal constraint.
1) Leading constraint priority :- 1000 Trailing constraint priority :- 1000
Content hugging priority :- Horizontal : 250 Vertical : 250
Content compression resistance priority :- Horizontal : 750 Vertical : 750
![](https://lh3.googleusercontent.com/SzBErmHkz8wlvgzLRYNG4a2MkKnrepkYr-ZF1LiFyxzdd5CSs8WFs7tbEh3jcQS0iXPn6785FBrf=w1920-h1080-no)
2) Leading constraint priority :- 500 Trailing constraint priority :- 500
Content hugging priority :- Horizontal : 750 Vertical : 750
Content compression resistance priority :- Horizontal : 750 Vertical : 750
![](https://lh3.googleusercontent.com/pYYlVUTxcO2lpc4Ymzu6DdNYlCT_rSrbq6EDlHu75JXs6cAgyBJ6ZdM1uZa2TUkzqoICSEI4cawzAoDZylfLFQLQw5w5G78=w1920-h1080-no)
As you can see above button size contracts to minimum size.
3) Leading constraint priority :- 500 Trailing constraint priority :- 500
Content hugging priority :- Horizontal : 750 Vertical : 750
Content compression resistance priority :- Horizontal : 250 Vertical : 250
First increase leading constraint constant and leading constraint constant by 50 points
![](https://lh3.googleusercontent.com/4MAePq98VXXIiRKvZVt8Zz2QB57o6H7khzGJwDQWPy-KVqQoUIX3jWafRhZHwuVm7d75KbaHz9tIFpzo55XGRBmc1GERCQY=w1920-h1080-no)
as you can see button text truncate from middle as content compression resistance is less than leading and trailing priority.
0 Comment(s)