Instance Property

intrinsicContentSize

The natural size for the receiving view, considering only properties of the view itself.

Declaration

var intrinsicContentSize: CGSize { get }

Discussion

Custom views typically have content that they display of which the layout system is unaware. Setting this property allows a custom view to communicate to the layout system what size it would like to be based on its content. This intrinsic size must be independent of the content frame, because there’s no way to dynamically communicate a changed width to the layout system based on a changed height, for example.

If a custom view has no intrinsic size for a given dimension, it can use UIViewNoIntrinsicMetric for that dimension.

See Also

Measuring in Auto Layout

func systemLayoutSizeFitting(CGSize)

Returns the size of the view that satisfies the constraints it holds.

func invalidateIntrinsicContentSize()

Invalidates the view’s intrinsic content size.

func contentCompressionResistancePriority(for: UILayoutConstraintAxis)

Returns the priority with which a view resists being made smaller than its intrinsic size.

func setContentCompressionResistancePriority(UILayoutPriority, for: UILayoutConstraintAxis)

Sets the priority with which a view resists being made smaller than its intrinsic size.

func contentHuggingPriority(for: UILayoutConstraintAxis)

Returns the priority with which a view resists being made larger than its intrinsic size.

func setContentHuggingPriority(UILayoutPriority, for: UILayoutConstraintAxis)

Sets the priority with which a view resists being made larger than its intrinsic size.