Instance Method

systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:

Returns the optimal size of the view based on its constraints and the specified fitting priorities.

Declaration

- (CGSize)systemLayoutSizeFittingSize:(CGSize)targetSize withHorizontalFittingPriority:(UILayoutPriority)horizontalFittingPriority verticalFittingPriority:(UILayoutPriority)verticalFittingPriority;

Parameters

targetSize

The size that you prefer for the view. To obtain a view that is as small as possible, specify the constant UILayoutFittingCompressedSize. To obtain a view that is as large as possible, specify the constant UILayoutFittingExpandedSize.

horizontalFittingPriority

The priority for horizontal constraints. Specify UILayoutPriorityFittingSizeLevel to get a width that is as close as possible to the width value of targetSize.

verticalFittingPriority

The priority for vertical constraints. Specify UILayoutPriorityFittingSizeLevel to get a height that is as close as possible to the height value of targetSize.

Return Value

The optimal size for the view based on the provided constraint priorities.

Discussion

Use this method when you want to prioritize the view's constraints when determining the best possible size of the view. This method does not actually change the size of the view.

See Also

Measuring in Auto Layout

- systemLayoutSizeFittingSize:

Returns the optimal size of the view based on its current constraints.

intrinsicContentSize

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

- invalidateIntrinsicContentSize

Invalidates the view’s intrinsic content size.

- contentCompressionResistancePriorityForAxis:

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

- setContentCompressionResistancePriority:forAxis:

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

- contentHuggingPriorityForAxis:

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

- setContentHuggingPriority:forAxis:

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