Swift version: 5.2
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 From January 26th to 31st you can join a FREE crash course for iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a senior developer!
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.