Software Dev

At a glance: hugging and resistance on iOS

Continuing the iOS at a glance series, giving you a quick visual of an iOS concept, let’s jump to and old and simple, but oddly confusing, topic: content-hugging priority and compression-resistance priority!

Okay, that is a mouthful for two simple, related ideas.

Apple is great at giving its consumer products some nice, catchy names. But the APIs? Well, they’re working on it. These are the guys who, long ago, gave us the “Autoresizing mask”.

Content hugging priority is basically how much a view “wants” to shrink down to its minimal size when put under pressure.

I’ll just call this “shrink-wrap-iness” because it shrinks down like plastic wrap.

While compression resistence priority is how much a view “wants” to expand when given the space.

I’ll call this “balloon-iness” because it expands like a balloon.

The higher the value in any direction, the “more” the view prioritizes that stance compared to other views.

So there it is at a glance. ✅ Hopefully that makes the idea more memorable, at least.

If that doesn’t help, maybe this will. 😉

For details and concrete examples, check out this article or this tutorial.

One thought on “At a glance: hugging and resistance on iOS

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.