Daily iOS
UIKit

Intrinsic Content Size

You put a custom view you built (say, a tag chip view) into a UIStackView and it's sized to zero and invisible. How would you explain the cause and the fix in terms of intrinsic content size?

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

A custom view doesn't tell Auto Layout its own size by default, so without size constraints it's computed as zero. Override intrinsicContentSize to return the content plus padding, and call invalidateIntrinsicContentSize() when the content changes so the engine reads the value again.

Share a question