Browse Questions
- intrinsicContentSize is the natural size a view prefers based on its content — like a label fitting its text, or a button fitting its title.
- Sendable is a protocol that marks a type as safe to share across concurrency domains (actors, tasks).
- Encrypt mode makes the payload unreadable to anyone but the named peer and also proves its origin, while sign/verify mode leaves the payload in the clear and only proves who produced it and that…
- Store tokens securely in the Keychain, attach them to requests via a header, and refresh automatically when a 401 is received.
Answer:
intrinsicContentSize is the natural size a view prefers based on its content — like a label fitting its text, or a button fitting its title. Auto Layout uses this when no explicit size constraint is set.
Code Example:
// UILabel and UIButton have intrinsicContentSize automatically
let label = UILabel()
label.text = "Hello"
print(label.intrinsicContentSize) // e.g. (33.0, 20.5)
// Custom view — override to declare your preferred size
class BadgeView: UIView {
var count: Int = 0 {
didSet { invalidateIntrinsicContentSize() } // tell Auto Layout size changed
}
override var intrinsicContentSize: CGSize {
let size = max(24, CGFloat(count) * 10)
return CGSize(width: size, height: 24)
}
}
// Return this to say "I have no opinion on this dimension"
return CGSize(width: UIView.noIntrinsicMetric, height: 44)