Daily iOS
UIKit

Auto Layout priorities

On a narrow screen, a title label and a price label have to share one row, and both demand their full text width. In Auto Layout, what decides which label gets truncated and which stays fully visible?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Set the price label's horizontal compression resistance higher than the title's (say, 751 vs 749) so the title shrinks and truncates when space runs short; when there's extra space, the side with lower content hugging stretches.

Share a question