Skip to content

Commit 174137d

Browse files
author
Luc Dion
committed
Add wrapContent documentation.
1 parent 7b39081 commit 174137d

File tree

7 files changed

+28
-21
lines changed

7 files changed

+28
-21
lines changed

README.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Extremely Fast views layouting without auto layout. No magic, pure code, full co
3737
* Swift 3.2+ / Swift 4.0 / Objective-C
3838

3939
### Recent features
40-
* :star: Add methods `wrapConten(...)` that adjust the view's width & height to wrap all its subviews. See [wrapContent](#wrapCcontent) for more information.
40+
* :star: Add `wrapContent()` methods that adjust view's width & height to wrap all its subviews. See [wrapContent](#wrapContent) for more information.
4141

4242
* :star: PinLayout now support macOS. See [macOS Support](#macos_support) for more information.
4343

@@ -1137,50 +1137,57 @@ This example runs perfectly on a iPhone X (iOS 11), but it also runs on any devi
11371137

11381138
<br/>
11391139

1140-
<a name="wrapCcontent"></a>
1140+
<a name="wrapContent"></a>
11411141
## WrapContent
11421142

1143-
The following methods are useful to adjust the view's width and/or height to wrap all its subviews. These method also adjust subviews position to create a tight wrap.
1143+
The following methods are useful to adjust view's width and/or height to wrap all its subviews. These methods also adjust subviews position to create a tight wrap.
11441144

11451145
**Methods:**
11461146

11471147
* **`wrapContent()`**
1148-
Bla.
1149-
* **`wrapContent(padding: CGFloat)`**
1150-
Bla.
1151-
* **`wrapContent(padding: UIEdgeInsets)`**
1152-
Bla.
1148+
**`wrapContent(padding: CGFloat)`**
1149+
**`wrapContent(padding: UIEdgeInsets)`**
1150+
Adjust the view's width and height to wrap all its subviews. The method also adjusts subviews position to create a tight wrap. It is also possible to specify an optional padding around all subviews.
11531151
* **`wrapContent(:WrapType)`**
1154-
Bla.
1155-
* **`wrapContent(:WrapType, padding: CGFloat)`**
1156-
Bla.
1157-
* **`wrapContent(:WrapType, padding: UIEdgeInsets)`**
1158-
Bla.
1159-
1160-
TABLE SHOWING DIFFERENCES!!!
1152+
**`wrapContent(:WrapType, padding: CGFloat)`** **`wrapContent(:WrapType, padding: UIEdgeInsets)`**
1153+
Adjust the view's width AND/OR height to wrap all its subviews. WrapType values are `.horizontally`/`.vertically`/`.all` It is also possible to specify an optional padding around all subviews.
11611154

11621155
###### Usage examples:
11631156
```swift
11641157
view.pin.wrapContent().center() // wrap all subviews and centered the view inside its parent.
11651158
view.pin.wrapContent(padding: 20) // wrap all subviews with a padding of 20 pixels all around
1159+
view.pin.wrapContent(.horizontally)
11661160
```
11671161

1168-
11691162
###### Example:
1170-
...:
1163+
This example show the result of different `wrapContent()` method calls.
1164+
Here is the initial state:
11711165

1172-
<img src="docs/pinlayout-example-justify-left.png" width="540"/>
1166+
<img src="docs/images/wrapContent_before.png" width="200"/>
11731167

1168+
| Source code | Result | Description |
1169+
|---------------------|----------|-------------------|
1170+
| `view.pin.wrapContent()` | <img src="docs/images/wrapContent_all.png" width="200"/> | Adjust the view's height and width to tight fit its subviews. |
1171+
| `view.pin.wrapContent(padding: 10)` | <img src="docs/images/wrapContent_padding.png" width="200"/> | Adjust the view's height and width and add a padding of 10 pixels around its subviews. |
1172+
| `view.pin.wrapContent(.horizontally)` | <img src="docs/images/wrapContent_horizontally.png" width="200"/> | Adjust only the view's width. |
1173+
| `view.pin.wrapContent(.vertically)` | <img src="docs/images/wrapContent_vertically.png" width="200"/> | Adjust only the view's height. |
1174+
1175+
1176+
###### Example:
1177+
This example shows how a view (`containerView`) with two subviews (`imageView` and `label`), can be adjusted to the size of its subviews and then centered inside its parent.
1178+
1179+
<img src="docs/images/wrapContent_example_1.png" width="540"/>
11741180

11751181
```swift
1176-
viewA.pin.....
1182+
label.pin.below(of: imageView, aligned: .center).marginTop(4)
1183+
containerView.pin.wrapContent().center()
11771184
```
1185+
* Line 1: Position the label below the imageView aligned on its center with a top margin of 4 pixels.
1186+
* Line 2: Adjust the `containerView`'s size and position its subviews to create a tight wrap around them, and then it center the `containerView` inside its parent (superview).
11781187

11791188
<br/>
11801189

11811190

1182-
1183-
11841191
<a name="justify_align"></a>
11851192
## justify() / align()
11861193

docs/images/wrapContent_all.png

25.3 KB
Loading

docs/images/wrapContent_before.png

25 KB
Loading
59.5 KB
Loading
25.6 KB
Loading
25.2 KB
Loading
25 KB
Loading

0 commit comments

Comments
 (0)