Swift version: 5.6
When Auto Layout has determined there isn't enough space to accommodate all your views at their natural size, it has to make a decision: one or more of those views needs to be squashed to make space for the others, but which one? That's where content compression resistance comes in: it's a value from 1 to 1000 that determines how happy you are for the view to be squashed if needed.
If you set a view's content compression resistance to be 1, it will be first in line to be squashed. If you set it to be 1000, it won't ever be squashed. The value is 750 by default, which means "I'd really prefer this not be squashed", but you might find you need to set it to be 751 or 749 on occasion, which means "I'd still really prefer this not to be squashed, but if there's no other choice…"
SPONSORED In-app subscriptions are a pain to implement, hard to test, and full of edge cases. RevenueCat makes it straightforward and reliable so you can get back to building your app. Oh, and it's free if your app makes less than $10k/mo.
Available from iOS 9.0
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.
Link copied to your pasteboard.