#JuniorTipThread
Let's talk AutoLayout.
AutoLayout is one of those things that until it clicks, it's super hard. Once it clicks, though, there's many new concepts that just keep building on top of it...
For example, content hugging and compression resistance.
1/6
Let's talk AutoLayout.
AutoLayout is one of those things that until it clicks, it's super hard. Once it clicks, though, there's many new concepts that just keep building on top of it...
For example, content hugging and compression resistance.

I fell into the classic trap where I'd set up my UI, then if one item was bigger than the others, so I'd just randomly move both content hugging and compression resistance until it behaved like I expected.
ngl, it took me a long time to understand it.
2/6
ngl, it took me a long time to understand it.

Yeah, doesn't matter if you're a senior, you're still prone to just wanting to get the thing done instead of learning. 
Anyway, content hugging and compression resistance basically allow you to determine which of two objects is going to expand or contract if...
3/6

Anyway, content hugging and compression resistance basically allow you to determine which of two objects is going to expand or contract if...

... the constraints demand it. A picture is worth a thousand words.
For example, what if you want your blue label to expand and the green label to contract? That's what content hugging and compression priorities are all about.
4/6
For example, what if you want your blue label to expand and the green label to contract? That's what content hugging and compression priorities are all about.

To explain it, here's this great article by Abhimuralidharan, which could be a really long name, a really long username or both. Names are hard.
https://abhimuralidharan.medium.com/ios-content-hugging-and-content-compression-resistance-priorities-476fb5828ef
Don't be lazy like me. Read the article, understand both concepts and save yourself a lot of time.
5/6
https://abhimuralidharan.medium.com/ios-content-hugging-and-content-compression-resistance-priorities-476fb5828ef
Don't be lazy like me. Read the article, understand both concepts and save yourself a lot of time.

This thread was also published in my latest newsletter! If you liked it, click here to join 
It helps since I'm trying to do this full time
https://mailchi.mp/hey/weekly-swift-exercise-signup
I also send weekly Swift exercises for beginners and intermediate learners alike!
6/6

It helps since I'm trying to do this full time

https://mailchi.mp/hey/weekly-swift-exercise-signup
I also send weekly Swift exercises for beginners and intermediate learners alike!
