#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
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
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
... 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
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
You can follow @fromjrtosr.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: