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
Copy file name to clipboardExpand all lines: README.md
+20-10Lines changed: 20 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,7 @@ Extremely Fast views layouting without auto layout. No magic, pure code, full co
39
39
40
40
### Recent changes/features
41
41
*:star: PinLayout can now layout CALayer. See [CALayer Support](#calayer_support) for more information.
42
+
*:star: PinLayout is in the Top 10 of Swift Layout frameworks on [Awesome Swift](https://swift.libhunt.com/categories/714-layout)
42
43
*:star: PinLayout has moved to the **[layoutBox](https://github.com/layoutBox)** organization. See other **[layoutBox](https://github.com/layoutBox)** projects.
43
44
*:star: Add `wrapContent()` methods that adjust view's width and height to wrap all its subviews. See [wrapContent](#wrapContent) for more information.
44
45
*:star: PinLayout now support macOS. See [macOS Support](#macos_support) for more information.
@@ -58,6 +59,7 @@ Extremely Fast views layouting without auto layout. No magic, pure code, full co
@@ -705,18 +707,23 @@ Set the view’s size to match the referenced view’s size
705
707
706
708
<br/>
707
709
708
-
<aname="sizeToFit"></a>
709
-
### sizeToFit
710
+
<aname="adjusting_size"></a>
711
+
### Adjusting size
710
712
711
-
**Method:**
713
+
PinLayout has methods to adjust the view’s size based on their content.
712
714
713
-
***`sizeToFit(_ fitType: FitType)`**
714
-
The method adjust the view's size based on the view's `sizeThatFits()` method result.
715
-
PinLayout will adjust either the view's width or height based on the `fitType` parameter value.
716
-
717
-
Notes:
718
-
* If margin rules apply, margins will be applied when determining the reference dimension (width/height).
719
-
* The resulting size will always respect `minWidth` / `maxWidth` / `minHeight` / `maxHeight`.
715
+
The resulting size will always respect [`minWidth`/`maxWidth`/`minHeight`/`maxHeight`](#minmax_width_height_size) values.
716
+
717
+
718
+
**Methods:**
719
+
720
+
***`sizeToFit()`**
721
+
The method adjust the view's size based on the result of the method `UIView.sizeToFit()`. Particularly useful for controls/views that have an intrinsic size (label, button, ...).
722
+
723
+
***`sizeToFit(: FitType)`**
724
+
The method adjust the view's size based on the result of the method `sizeThatFits(:CGSize)`.
725
+
PinLayout will adjust either the view's width or height based on the `fitType` parameter value.
726
+
If margins are specified, they will be applied before calling the view's `sizeThatFits(:CGSize)` method.
720
727
721
728
**Parameter `fitType`:** Identify the reference dimension (width / height) that will be used to adjust the view's size.
722
729
@@ -736,6 +743,9 @@ The method adjust the view's size based on the view's `sizeThatFits()` method re
736
743
###### Usage examples:
737
744
738
745
```swift
746
+
// Adjust the view's size based on the result of `UIView.sizeToFit()` and center it.
747
+
view.pin.center().sizeToFit()
748
+
739
749
// Adjust the view's size based on a width of 100 pixels.
740
750
// The resulting width will always match the pinned property `width(100)`.
0 commit comments