Skip to content

Commit 9bbedaa

Browse files
author
Luc Dion
committed
Update documentation + version to 1.6.0
1 parent 902ce67 commit 9bbedaa

File tree

4 files changed

+66
-53
lines changed

4 files changed

+66
-53
lines changed

CHANGELOG.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,46 @@
77

88
# Change Log
99

10-
## [1.6.0](https://github.com/layoutBox/FlexLayout/releases/tag/1.5.9)
11-
Released on 2018-02-18
10+
## [1.6.0](https://github.com/layoutBox/FlexLayout/releases/tag/1.6.0)
11+
Released on 2018-03-22
1212

13-
Additions:
13+
### UIView.pin.safeArea
14+
PinLayout can handle easily iOS 11 UIView.safeAreaInsets, but it goes further by supporting safeAreaInsets for previous iOS releases (including iOS 7/8/9/10) by adding a property UIView.pin.safeArea. PinLayout also extend the support of UIView.safeAreaInsetsDidChange() callback on iOS 7/8/9/10.
1415

15-
* **`UIView.pin.safeArea`**
16-
The safe area of a view represent the area not covered by navigation bars, tab bars, toolbars, and other ancestors that obscure a view controller's view.
16+
See [UIView.pin.safeArea Documentation](https://github.com/mirego/PinLayout#safeAreaInsets) for more details.
1717

18-
* `all(_ insets: UIEdgeInsets)`
19-
* `horizontally(_ insets: UIEdgeInsets)`
20-
* `vertically(_ percent: Percent)`
18+
Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#125](https://github.com/mirego/PinLayout/pull/125)
2119

22-
Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#122](https://github.com/mirego/PinLayout/pull/122)
2320

21+
### Add methods taking UIEdgeInset as parameter
22+
* `all(_ insets: UIEdgeInsets)`
23+
* `horizontally(_ insets: UIEdgeInsets)`
24+
* `vertically(_ insets: UIEdgeInsets)`
25+
* `top(_ insets: UIEdgeInsets)`
26+
* `bottom(_ insets: UIEdgeInsets)`
27+
* `left(_ insets: UIEdgeInsets)`
28+
* `right(_ insets: UIEdgeInsets)`
29+
30+
See [Layout using distances from superview’s edges](https://github.com/mirego/PinLayout#layout-using-distances-from-superviews-edges) for more details.
31+
32+
Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#125](https://github.com/mirego/PinLayout/pull/125)
33+
34+
### Add margins method with percentage parameter
35+
36+
* `marginTop(_ percent: Percent)`
37+
* `marginLeft(_ percent: Percent)`
38+
* `marginBottom(_ percent: Percent)`
39+
* `marginLeft(_ percent: Percent)`
40+
* `marginStart(_ percent: Percent)`
41+
* `marginEnd(_ percent: Percent)`
42+
* `marginHorizontal(_ percent: Percent)`
43+
* `marginVertical(_ percent: Percent)`
44+
* `margin(_ percent: Percent)`
45+
* `margin(_ vertical: Percent, _ horizontal: Percent)`
46+
* `margin(_ top: Percent, _ horizontal: Percent, _ bottom: Percent)`
47+
* `margin(_ top: Percent, _ left: Percent, _ bottom: Percent, _ right: Percent)`
48+
49+
Added by [vandyshev](https://github.com/vandyshev) in Pull Request [#126](https://github.com/mirego/PinLayout/pull/126)
2450

2551
## [1.5.9](https://github.com/layoutBox/FlexLayout/releases/tag/1.5.9)
2652
Released on 2018-02-18

PinLayout.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = "PinLayout"
11-
s.version = "1.5.9"
11+
s.version = "1.6.0"
1212
s.summary = "Fast Swift UIViews layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable."
1313
s.description = "Fast Swift UIViews layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable."
1414

README.md

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,16 @@ PinLayout can position a view’s edge relative to its superview edges.
183183
**Methods**:
184184

185185
* **`top(:CGFloat)`** / **`top(:Percent)`** / **`top()`** / **`top(:UIEdgeInsets)`**
186-
The value specifies the top edge distance from the superview's top edge in pixels (or in percentage of its superview's height). `top()` is similar to calling `top(0)`, it position the view top edge directly on its superview top edge. `top(:UIEdgeInsets)` use the `UIEdgeInsets.top` property, is particularly useful with [`pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
186+
The value specifies the top edge distance from the superview's top edge in pixels (or in percentage of its superview's height). `top()` is similar to calling `top(0)`, it position the view top edge directly on its superview top edge. `top(:UIEdgeInsets)` use the `UIEdgeInsets.top` property, is particularly useful with [`UIView.pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
187187

188188
* **`bottom(:CGFloat)`** / **`bottom(:Percent)`** / **`bottom()`** / **`bottom(:UIEdgeInsets)`**
189-
The value specifies the bottom edge **distance from the superview's bottom edge** in pixels (or in percentage of its superview's height). `bottom()` is similar to calling `bottom(0)`, it position the view bottom edge directly on its superview top edge. `bottom(:UIEdgeInsets)` use the `UIEdgeInsets.bottom` property, it is is particularly useful with [`pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
189+
The value specifies the bottom edge **distance from the superview's bottom edge** in pixels (or in percentage of its superview's height). `bottom()` is similar to calling `bottom(0)`, it position the view bottom edge directly on its superview top edge. `bottom(:UIEdgeInsets)` use the `UIEdgeInsets.bottom` property, it is is particularly useful with [`UIView.pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
190190

191191
* **`left(:CGFloat)`** / **`left(:Percent)`** / **`left()`** / **`left(:UIEdgeInsets)`**
192-
The value specifies the left edge distance from the superview's left edge in pixels (or in percentage of its superview's width). `left()` is similar to calling `left(0)`, it position the view left edge directly on its superview left edge. `left(:UIEdgeInsets)` use the `UIEdgeInsets.left` property, it is particularly useful with [`pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
192+
The value specifies the left edge distance from the superview's left edge in pixels (or in percentage of its superview's width). `left()` is similar to calling `left(0)`, it position the view left edge directly on its superview left edge. `left(:UIEdgeInsets)` use the `UIEdgeInsets.left` property, it is particularly useful with [`UIView.pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
193193

194194
* **`right(:CGFloat)`** / **`right(:Percent)`** / **`right()`** / **`right(:UIEdgeInsets)`**
195-
The value specifies the right edge **distance from the superview's right edge** in pixels (or in percentage of its superview's width). `right()` is similar to calling `right(0)`, it position the view right edge directly on its superview right edge. `right(:UIEdgeInsets)` use the `UIEdgeInsets. right` property, it is particularly useful with [`pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
195+
The value specifies the right edge **distance from the superview's right edge** in pixels (or in percentage of its superview's width). `right()` is similar to calling `right(0)`, it position the view right edge directly on its superview right edge. `right(:UIEdgeInsets)` use the `UIEdgeInsets. right` property, it is particularly useful with [`UIView.pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
196196

197197
* **`vCenter(:CGFloat)`** / **`vCenter(:Percent)`** / **`vCenter()`**
198198
The value specifies the distance vertically of the view's center related to the superview's center in pixels (or in percentage of its superview's height). A positive value move the view down and a negative value move it up relative to the superview's center. `vCenter()` is similar to calling `vCenter(0)`, it position vertically the view's center directly on its superview vertical center.
@@ -203,19 +203,19 @@ The value specifies the distance horizontally of the view's center related to th
203203
* **`start(:CGFloat)`** / **`start(:Percent)`** / **`start()`** / **`start(:UIEdgeInsets)`** :left_right_arrow:
204204
In LTR direction the value specifies the left edge distance from the superview's left edge in pixels (or in percentage of its superview's width).
205205
In RTL direction the value specifies the right edge distance from the superview's right edge in pixels (or in percentage of its superview's width).
206-
`start()` is similar to calling `start(0)`. `start(:UIEdgeInsets)` use the `UIEdgeInsets.left` property in LTR direction and `UIEdgeInsets.right` in RTL direction, it is particularly useful with [`pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
206+
`start()` is similar to calling `start(0)`. `start(:UIEdgeInsets)` use the `UIEdgeInsets.left` property in LTR direction and `UIEdgeInsets.right` in RTL direction, it is particularly useful with [`UIView.pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
207207

208208
* **`end(:CGFloat)`** / **`end(:Percent)`** / **`end()`** / **`end(:UIEdgeInsets)`** :left_right_arrow:
209209
In LTR direction the value specifies the right edge distance from the superview's right edge in pixels (or in percentage of its superview's width).
210-
In RTL direction the value specifies the left edge distance from the superview's left edge in pixels (or in percentage of its superview's width). `end()` is similar to calling `end(0)`. `end(:UIEdgeInsets)` use the `UIEdgeInsets.right` property in LTR direction and `UIEdgeInsets.left` in RTL direction, it is particularly useful with [`pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
210+
In RTL direction the value specifies the left edge distance from the superview's left edge in pixels (or in percentage of its superview's width). `end()` is similar to calling `end(0)`. `end(:UIEdgeInsets)` use the `UIEdgeInsets.right` property in LTR direction and `UIEdgeInsets.left` in RTL direction, it is particularly useful with [`UIView.pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
211211

212212
<a name="pin_multiple_edges"></a>
213213
**Methods pinning multiple edges**:
214214

215215
* **`all(:CGFloat)`** / **`all(:UIEdgeInsets)`** / **`all()`**
216216
The value/insets specifies the **top, bottom, left and right edges** distance from the superview's corresponding edge in pixels. Similar to calling `view.top(value).bottom(value).left(value).right(value)`.
217217
`all()` is similar to calling `all(0)`.
218-
`all(:UIEdgeInsets)` is particularly useful with [`pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
218+
`all(:UIEdgeInsets)` is particularly useful with [`UIView.pin.safeArea`](#safeAreaInsets) or `UIView.safeAreaInsets`.
219219

220220
* **`horizontally(:CGFloat)`** / **`horizontally(:Percent)`** /
221221
**`horizontally(:UIEdgeInsets)`** / **`horizontally()`**
@@ -851,42 +851,41 @@ This example layout an UIImageView at the top and center it horizontally, it als
851851

852852
<a name="margins"></a>
853853
## Margins
854-
PinLayout applies margins similar to CSS.
855854

856-
857-
### PinLayout's margins
858-
859-
PinLayout has methods to apply margins.
855+
PinLayout has methods to apply margins. PinLayout applies margins similar to CSS.
860856

861857
**Methods:**
862858

863-
* **`marginTop(:CGFloat)`**
864-
Set the top margin.
865-
* **`marginLeft(:CGFloat)`**
866-
Set the left margin.
867-
* **`marginBottom(:CGFloat)`**
868-
Set the bottom margin.
869-
* **`marginRight(:CGFloat)`**
870-
Set the right margin.
871-
* **`marginStart(:CGFloat)`**:left_right_arrow:
859+
* **`marginTop(:CGFloat)`** / **`marginTop(: Percent)`**
860+
Set the top margin in pixels or in percentage of its superview's height.
861+
* **`marginLeft(:CGFloat)`** / **`marginLeft(: Percent)`**
862+
Set the left margin in pixels or in percentage of its superview's width.
863+
* **`marginBottom(:CGFloat)`** / **`marginBottom(: Percent)`**
864+
Set the bottom margin in pixels or in percentage of its superview's height
865+
* **`marginRight(:CGFloat)`** / **`marginRight(: Percent)`**
866+
Set the right margin in pixels or in percentage of its superview's width.
867+
* **`marginStart(:CGFloat)`** / **`marginStart(: Percent)`** :left_right_arrow:
872868
Set the start margin. Depends on the value of `Pin.layoutDirection(...)`. In LTR direction, start margin specify the **left** margin. In RTL direction, start margin specify the **right** margin.
873-
* **`marginEnd(:CGFloat)`**:left_right_arrow:
869+
* **`marginEnd(:CGFloat)`** / **`marginEnd(: Percent)`** :left_right_arrow:
874870
Set the end margin. Depends on the value of `Pin.layoutDirection(...)`. In LTR direction, end margin specify the **right** margin. In RTL direction, end margin specify the **left** margin.
875-
* **`marginHorizontal(:CGFloat)`**
871+
* **`marginHorizontal(:CGFloat)`** / **`marginHorizontal(: Percent)`**
876872
Set the left, right, start and end margins to the specified value
877-
* **`marginVertical(:CGFloat)`**
873+
* **`marginVertical(:CGFloat)`** / **`marginVertical(: Percent)`**
878874
Set the top and bottom margins to the specified value.
879-
* **`margin(:CGFloat)`**
880-
Apply the value to all margins (top, left, bottom, right)
875+
* **`margin(:CGFloat)`** / **`margin(: Percent)`**
876+
Apply the value to all margins (top, left, bottom, right), in pixels or in percentage of its superview's width/height.
881877
* **`margin(:UIEdgeInsets)`**
882-
Set all margins using an UIEdgeInsets. This method is particularly useful to set all margins using iOS 11 with `UIView.safeAreaInsets` or [`pin.safeArea`](#safeAreaInsets).
878+
Set all margins using an UIEdgeInsets. This method is particularly useful to set all margins using iOS 11 with `UIView.safeAreaInsets` or [`UIView.pin.safeArea`](#safeAreaInsets).
883879
* **`margin(_ insets: NSDirectionalEdgeInsets) `**
884880
Set all margins using an NSDirectionalEdgeInsets. This method is useful to set all margins using iOS 11 `UIView. directionalLayoutMargins` when layouting a view supporting RTL/LTR languages.
885881
* **`margin(_ vertical: CGFloat, _ horizontal: CGFloat)`**
882+
**`margin(_ vertical: Percent, _ horizontal: Percent)`**
886883
Set the individually vertical margins (top, bottom) and horizontal margins (left, right, start, end)
887884
* **`margin(_ top: CGFloat, _ horizontal: CGFloat, _ bottom: CGFloat)`**
885+
**`margin(_ top: Percent, _ horizontal: Percent, _ bottom: Percent)`**
888886
Set individually top, horizontal margins and bottom margin
889-
* **`margin(_ top: CGFloat, _ right: CGFloat, _ bottom: CGFloat, _ left: CGFloat)`**
887+
* **`margin(_ top: CGFloat, _ right: CGFloat, _ bottom: CGFloat, _ left: CGFloat)`**
888+
**`margin(_ top: Percent, _ left: Percent, _ bottom: Percent, _ right: Percent)`**
890889

891890
###### Usage examples:
892891
```swift
@@ -1089,7 +1088,7 @@ The safe area of a view represent the area not covered by navigation bars, tab b
10891088
<br>
10901089

10911090
###### Example using `UIView.pin.safeArea`
1092-
This example layout 4 subviews inside the safeArea. The UINavigationBar and UITabBar are translucent, so even if the container UIView goes under both, we can use its `pin.safeArea` to keeps its subviews within the safeArea.
1091+
This example layout 4 subviews inside the safeArea. The UINavigationBar and UITabBar are translucent, so even if the container UIView goes under both, we can use its `UIView.pin.safeArea` to keeps its subviews within the safeArea.
10931092

10941093
<img src="docs/images/pinlayout_safearea_example_iphonex.png" width="540"/>
10951094

@@ -1417,7 +1416,7 @@ There is an Example app that expose some usage example on PinLayout, including:
14171416
* The [introduction example](#intro_usage_example) presented previously in this README.
14181417
* UITableView example with variable height cells.
14191418
* UICollectionView example.
1420-
* An example using PinLayout's [`pin.safeArea`](#safeAreaInsets)
1419+
* An example using PinLayout's [`UIView.pin.safeArea`](#safeAreaInsets)
14211420
* An RTL enabled version of the [introduction example](#intro_usage_example)
14221421
* An example showing of the right-to-left (RTL) language support. Similar to the Intro example.
14231422
* Example showing a form
@@ -1467,7 +1466,7 @@ PinLayout also expose an Objective-C interface slightly different than the Swift
14671466
**R:** PinLayout doesn't use auto layout constraints, it is a framework that manually layout views. For that reason you need to update the layout inside either `UIView.layoutSubviews()` or `UIViewController.viewDidLayoutSubviews()` to handle container size's changes, including device rotation. You'll also need to handle UITraitCollection changes for app's that support multitasking.
14681467

14691468
* **Q: How to handle new iOS 11 `UIView.safeAreaInsets` and the iPhone X .**
1470-
**R:** iOS 11 has introduced `UIView.safeAreaInsets` to particularly support the iPhone X landscape mode. In this mode `UIView.safeAreaInsets` has a left and right insets. The easiest way the handle this situation with PinLayout is to add a contentView that will contains all your view's child, and simply adjust this contentView view to match the `safeAreaInsets` or PinLayout's [`pin.safeArea`](#safeAreaInsets).
1469+
**R:** iOS 11 has introduced `UIView.safeAreaInsets` to particularly support the iPhone X landscape mode. In this mode `UIView.safeAreaInsets` has a left and right insets. The easiest way the handle this situation with PinLayout is to add a contentView that will contains all your view's child, and simply adjust this contentView view to match the `safeAreaInsets` or PinLayout's [`UIView.pin.safeArea`](#safeAreaInsets).
14711470

14721471
All example in the [Examples App](#examples_app) handle correctly the `safeAreaInsets` and works on iPhone X in landscape mode. Many PinLayout's method accept an UIEdgeInsets as parameter.
14731472

Sources/PinLayout.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -423,28 +423,24 @@ public protocol PinLayout {
423423
Set the top margin.
424424
*/
425425
@discardableResult func marginTop(_ value: CGFloat) -> PinLayout
426-
427426
@discardableResult func marginTop(_ percent: Percent) -> PinLayout
428427

429428
/**
430429
Set the left margin.
431430
*/
432431
@discardableResult func marginLeft(_ value: CGFloat) -> PinLayout
433-
434432
@discardableResult func marginLeft(_ percent: Percent) -> PinLayout
435433

436434
/**
437435
Set the bottom margin.
438436
*/
439437
@discardableResult func marginBottom(_ value: CGFloat) -> PinLayout
440-
441438
@discardableResult func marginBottom(_ percent: Percent) -> PinLayout
442439

443440
/**
444441
Set the right margin.
445442
*/
446443
@discardableResult func marginRight(_ value: CGFloat) -> PinLayout
447-
448444
@discardableResult func marginRight(_ percent: Percent) -> PinLayout
449445

450446
// RTL support
@@ -456,7 +452,6 @@ public protocol PinLayout {
456452
* In RTL direction, start margin specify the **right** margin.
457453
*/
458454
@discardableResult func marginStart(_ value: CGFloat) -> PinLayout
459-
460455
@discardableResult func marginStart(_ percent: Percent) -> PinLayout
461456

462457
/**
@@ -467,21 +462,18 @@ public protocol PinLayout {
467462
* In RTL direction, end margin specify the **left** margin.
468463
*/
469464
@discardableResult func marginEnd(_ value: CGFloat) -> PinLayout
470-
471465
@discardableResult func marginEnd(_ percent: Percent) -> PinLayout
472466

473467
/**
474468
Set the left, right, start and end margins to the specified value.
475469
*/
476470
@discardableResult func marginHorizontal(_ value: CGFloat) -> PinLayout
477-
478471
@discardableResult func marginHorizontal(_ percent: Percent) -> PinLayout
479472

480473
/**
481474
Set the top and bottom margins to the specified value.
482475
*/
483476
@discardableResult func marginVertical(_ value: CGFloat) -> PinLayout
484-
485477
@discardableResult func marginVertical(_ percent: Percent) -> PinLayout
486478

487479
/**
@@ -503,28 +495,24 @@ public protocol PinLayout {
503495
Set all margins to the specified value.
504496
*/
505497
@discardableResult func margin(_ value: CGFloat) -> PinLayout
506-
507498
@discardableResult func margin(_ percent: Percent) -> PinLayout
508499

509500
/**
510501
Set individually vertical margins (top, bottom) and horizontal margins (left, right, start, end).
511502
*/
512503
@discardableResult func margin(_ vertical: CGFloat, _ horizontal: CGFloat) -> PinLayout
513-
514504
@discardableResult func margin(_ vertical: Percent, _ horizontal: Percent) -> PinLayout
515505

516506
/**
517507
Set individually top, horizontal margins and bottom margin.
518508
*/
519509
@discardableResult func margin(_ top: CGFloat, _ horizontal: CGFloat, _ bottom: CGFloat) -> PinLayout
520-
521510
@discardableResult func margin(_ top: Percent, _ horizontal: Percent, _ bottom: Percent) -> PinLayout
522511

523512
/**
524513
Set individually top, left, bottom and right margins.
525514
*/
526515
@discardableResult func margin(_ top: CGFloat, _ left: CGFloat, _ bottom: CGFloat, _ right: CGFloat) -> PinLayout
527-
528516
@discardableResult func margin(_ top: Percent, _ left: Percent, _ bottom: Percent, _ right: Percent) -> PinLayout
529517

530518
/// Normally if only either left or right has been specified, PinLayout will MOVE the view to apply left or right margins.

0 commit comments

Comments
 (0)