You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -706,18 +707,24 @@ Set the view’s size to match the referenced view’s size
706
707
707
708
<br/>
708
709
709
-
<aname="sizeToFit"></a>
710
-
### sizeToFit
710
+
<aname="adjusting_size"></a>
711
+
### Adjusting size
711
712
712
-
**Method:**
713
+
PinLayout has methods to adjust the view’s size based on their content.
714
+
715
+
716
+
**Methods:**
717
+
718
+
***`sizeToFit()`**
719
+
The method adjust the view's size based on the result of the method `UIView.sizeToFit()`. The size will respect `minWidth` / `maxWidth` / `minHeight` / `maxHeight`.
713
720
714
721
***`sizeToFit(_ fitType: FitType)`**
715
-
The method adjust the view's size based on the view's `sizeThatFits()` method result.
722
+
The method adjust the view's size based on the result of the method `sizeThatFits(:CGSize)`.
716
723
PinLayout will adjust either the view's width or height based on the `fitType` parameter value.
717
724
718
725
Notes:
719
-
* If margin rules apply, margins will be applied when determining the reference dimension (width/height).
720
726
* The resulting size will always respect `minWidth` / `maxWidth` / `minHeight` / `maxHeight`.
727
+
* If margins have been specified, they will be applied before calling the view's `sizeThatFits(:CGSize)` method.
721
728
722
729
**Parameter `fitType`:** Identify the reference dimension (width / height) that will be used to adjust the view's size.
723
730
@@ -737,6 +744,9 @@ The method adjust the view's size based on the view's `sizeThatFits()` method re
737
744
###### Usage examples:
738
745
739
746
```swift
747
+
// Adjust the view's size based on the result of `UIView.sizeToFit()` and center it.
748
+
view.pin.center().sizeToFit()
749
+
740
750
// Adjust the view's size based on a width of 100 pixels.
741
751
// The resulting width will always match the pinned property `width(100)`.
0 commit comments