Skip to content

Commit a729350

Browse files
author
Luc Dion
committed
Update readme.md
1 parent d1c95f2 commit a729350

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ override func layoutSubviews() {
8383

8484
logo.pin.top().left().size(100).aspectRatio().margin(10)
8585
segmented.pin.after(of: logo, aligned: .top).right().marginHorizontal(10)
86-
textLabel.pin.below(of: segmented, aligned: .left).right().marginTop(10).marginRight(10).fitWidth()
86+
textLabel.pin.below(of: segmented, aligned: .left).right().marginTop(10).marginRight(10).sizeToFit(.width)
8787
separatorView.pin.below(of: [logo, textLabel], aligned: .left).right(to: segmented.edge.right).marginTop(10)
8888
}
8989
```
@@ -109,11 +109,11 @@ This example shows how easily PinLayout can adjust its layout based on the view'
109109
let margin: CGFloat = 12
110110

111111
if frame.width < 500 {
112-
textLabel.pin.top().left().right().margin(margin).fitWidth()
112+
textLabel.pin.top().left().right().margin(margin).sizeToFit(.width)
113113
segmentedControl.pin.below(of: textLabel).right().margin(margin)
114114
} else {
115115
segmentedControl.pin.top().right().margin(margin)
116-
textLabel.pin.top().left().before(of: segmentedControl).margin(margin).fitWidth()
116+
textLabel.pin.top().left().before(of: segmentedControl).margin(margin).sizeToFit(.width)
117117
}
118118
```
119119

@@ -786,15 +786,11 @@ The method adjust the view's size based on the view's `sizeThatFits()` method re
786786
**Parameter `fitType`:** Identify the reference dimension (width / height) that will be used to adjust the view's size.
787787

788788
* **`.width`**: The method adjust the view's size based on the **reference width**.
789-
* If properties related to the width have been pinned (e.g: width, left & right, margins, ...),
790-
the **reference width will be determined by these properties**, else the **current view's width**
791-
will be used.
789+
* If properties related to the width have been pinned (e.g: width, left & right, margins, ...), the **reference width will be determined by these properties**, if not the **current view's width** will be used.
792790
* The resulting width will always **match the reference width**.
793791

794792
* **`.height`**: The method adjust the view's size based on the **reference height**.
795-
* If properties related to the height have been pinned (e.g: height, top & bottom, margins, ...),
796-
the **reference height will be determined by these properties**, else the **current view's height**
797-
will be used.
793+
* If properties related to the height have been pinned (e.g: height, top & bottom, margins, ...), the **reference height will be determined by these properties**, if not the **current view's height** will be used.
798794
* The resulting height will always **match the reference height**.
799795

800796
* **`.widthFlexible`**: Similar to `.width`, except that PinLayout won't constrain the resulting width to match the reference width. The resulting width may be smaller of bigger depending on the view's sizeThatFits(..) method result. For example a single line UILabel may returns a smaller width if its string is smaller than the reference width.
@@ -1192,14 +1188,14 @@ Warnings can be disabled also in debug mode by setting the boolean Pin.logWarnin
11921188
## PinLayout style guide
11931189

11941190
* You should always specifies methods in the same order, it makes layout lines easier to understand. Here is our prefered ordering:
1195-
`view.pin.[EDGE|ANCHOR|RELATIVE].[WIDTH|HEIGHT|SIZE].[pinEdges()].[MARGINS].[fitWidth()/fitHeight()]`
1191+
`view.pin.[EDGE|ANCHOR|RELATIVE].[WIDTH|HEIGHT|SIZE].[pinEdges()].[MARGINS].[sizeToFit()]`
11961192

1197-
This order reflect the logic inside PinLayout. `pinEdges()` is applied before margins and margins are applied before `fitWidth()/fitHeight()`.
1193+
This order reflect the logic inside PinLayout. `pinEdges()` is applied before margins and margins are applied before `sizeToFit()`.
11981194

11991195
```swift
12001196
view.pin.top().left(10%).margin(10, 12, 10, 12)
12011197
view.pin.left().width(100%).pinEdges().marginHorizontal(12)
1202-
view.pin.left().right().margin(0, 12).fitWidth()
1198+
view.pin.left().right().margin(0, 12).sizeToFit(.width)
12031199
view.pin.width(100).height(100%)
12041200
```
12051201

Sources/PinLayout.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,13 @@ public protocol PinLayout {
339339

340340
.width: The method adjust the view's size based on the **reference width**.
341341
* If properties related to the width have been pinned (e.g: width, left & right, margins, ...),
342-
the **reference width will be determined by these properties**, else the **current view's width**
342+
the **reference width will be determined by these properties**, if not the **current view's width**
343343
will be used.
344344
* The resulting width will always **match the reference width**.
345345

346346
.height: The method adjust the view's size based on the **reference height**.
347347
* If properties related to the height have been pinned (e.g: height, top & bottom, margins, ...),
348-
the **reference height will be determined by these properties**, else the **current view's height**
348+
the **reference height will be determined by these properties**, if not the **current view's height**
349349
will be used.
350350
* The resulting height will always **match the reference height**.
351351

0 commit comments

Comments
 (0)