Skip to content

Commit 50793a5

Browse files
author
Luc Dion
committed
Update Readme
1 parent d2516d2 commit 50793a5

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Extremely Fast views layouting without auto layout. No magic, pure code, full co
5959
* [Anchors](#anchors)
6060
* [Relative positioning](#relative_positioning)
6161
* [Width, height and size](#width_height_size)
62+
* [Adjusting size](#adjusting_size)
6263
* [minWidth, maxWidth, minHeight, maxHeight](#minmax_width_height_size)
6364
* [Aspect Ratio](#aspect_ratio)
6465
* [Margins](#margins)
@@ -706,18 +707,24 @@ Set the view’s size to match the referenced view’s size
706707

707708
<br/>
708709

709-
<a name="sizeToFit"></a>
710-
### sizeToFit
710+
<a name="adjusting_size"></a>
711+
### Adjusting size
711712

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`.
713720

714721
* **`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)`.
716723
PinLayout will adjust either the view's width or height based on the `fitType` parameter value.
717724

718725
Notes:
719-
* If margin rules apply, margins will be applied when determining the reference dimension (width/height).
720726
* 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.
721728

722729
**Parameter `fitType`:** Identify the reference dimension (width / height) that will be used to adjust the view's size.
723730

@@ -737,6 +744,9 @@ The method adjust the view's size based on the view's `sizeThatFits()` method re
737744
###### Usage examples:
738745

739746
```swift
747+
// Adjust the view's size based on the result of `UIView.sizeToFit()` and center it.
748+
view.pin.center().sizeToFit()
749+
740750
// Adjust the view's size based on a width of 100 pixels.
741751
// The resulting width will always match the pinned property `width(100)`.
742752
view.pin.width(100).sizeToFit(.width)

0 commit comments

Comments
 (0)