systemLayoutSizeFitting(_:)
Returns the optimal size of the view based on its current constraints.
Declaration
func systemLayoutSizeFitting(_ targetSize: CGSize) -> CGSizeParameters
- targetSize:
The size that you prefer for the view. To obtain a view that is as small as possible, specify the constant Layoutfittingcompressedsize. To obtain a view that is as large as possible, specify the constant Layoutfittingexpandedsize.
Return Value
The optimal size for the view.
Discussion
This method returns a size value for the view that optimally satisfies the view’s current constraints and is as close to the value in the targetSize parameter as possible. This method does not actually change the size of the view.