Skip to content

Commit 142acdf

Browse files
committed
Readme adjustments
1 parent bba716a commit 142acdf

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Extremely Fast views layouting without auto layout. No magic, pure code, full co
7272
* [safeArea, readable and layout margins](#safeAreaInsets)
7373
* [WrapContent](#wrapContent)
7474
* [justify, align](#justify_align)
75+
* [Automatic sizing](#automatic_sizing)
7576
* [UIView's transforms](#uiview_transform)
7677
* [Warnings](#warnings)
7778
* [Animations using PinLayout](#animations)
@@ -1477,7 +1478,7 @@ This example centered horizontally the view B in the space remaining at the righ
14771478

14781479
<br/>
14791480

1480-
<a name="justify_align"></a>
1481+
<a name="automatic_sizing"></a>
14811482
## Automatic Sizing
14821483
Sizing views as part of the manual layout process is made with `sizeThatFits(_ size: CGSize)` where a view returns its ideal size given his parent size. Implementing sizing code has always been cumbersome because you always end up writing the same code twice, a first time for the layout and the second time for sizing. Sizing usually use the same rules layout does but implemented slightly differently because no subview `frame` should be mutated during sizing. Since `PinLayout` already takes care of the layout, it makes perfect sense to leverage it's layout engine to compute sizing.
14831484

@@ -1504,20 +1505,20 @@ Sizing views as part of the manual layout process is made with `sizeThatFits(_ s
15041505

15051506
###### Usage examples:
15061507
```swift
1507-
override func layoutSubviews() {
1508+
override func layoutSubviews() {
15081509
super.layoutSubviews()
15091510
performLayout()
15101511
didPerformLayout()
15111512
}
15121513

15131514
private func performLayout() {
1514-
scrollView.pin.all()
1515+
scrollView.pin.all()
15151516
imageView.pin.top().horizontally().sizeToFit(.width).margin(margin)
15161517
textLabel.pin.below(of: imageView).horizontally().sizeToFit(.width).margin(margin)
15171518
}
15181519

15191520
private func didPerformLayout() {
1520-
scrollView.contentSize = CGSize(width: scrollView.bounds.width, height: textLabel.frame.maxY + margin)
1521+
scrollView.contentSize = CGSize(width: scrollView.bounds.width, height: textLabel.frame.maxY + margin)
15211522
}
15221523

15231524
override func sizeThatFits(_ size: CGSize) -> CGSize {
@@ -1801,6 +1802,7 @@ Included examples:
18011802
* Example showing how to animate with PinLayout.
18021803
* Example using [`pin.safeArea`, `pin.readableMargins` and `pin.layoutMargins`](#safeAreaInsets)
18031804
* Example using [`wrapContent()`](#wrapContent)
1805+
* Example using [`autoSizeThatFits`](#automatic_sizing)
18041806
* Example showing right-to-left (RTL) language support.
18051807
* Example showing a simple form example
18061808
* Example showing Relative Edges layout.
@@ -1817,6 +1819,7 @@ Included examples:
18171819
<a href="https://github.com/layoutBox/PinLayout/blob/master/Example/PinLayoutSample/UI/Examples/AutoAdjustingSize/AutoAdjustingSizeView.swift"><img src="docs/pinlayout_exampleapp_auto_adjusting_size.png" width=120/></a>
18181820
<a href="https://github.com/layoutBox/PinLayout/blob/master/Example/PinLayoutSample/UI/Examples/RelativeView/RelativeView.swift"><img src="docs/pinlayout_exampleapp_relative_position.png" width=120/> </a>
18191821
<a href="https://github.com/layoutBox/PinLayout/blob/master/Example/PinLayoutSample/UI/Examples/BetweenView/BetweenView.swift"><img src="docs/pinlayout_exampleapp_multi_relative_position.png" width=120/></a>
1822+
<a href="https://github.com/layoutBox/PinLayout/blob/master/Example/PinLayoutSample/UI/Examples/AutoSizing/AutoSizingContainerView.swift"><img src="pinlayout_exampleapp_automatic_sizing.png" width=120/></a>
18201823
</p>
18211824

18221825
<br>
696 KB
Loading

0 commit comments

Comments
 (0)