Skip to content

Commit a2edab3

Browse files
author
Luc Dion
committed
Update to version 1.2.4 + README update
1 parent f98a4a0 commit a2edab3

File tree

3 files changed

+97
-72
lines changed

3 files changed

+97
-72
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
# Change Log
99

10+
## [1.2.4](https://github.com/mirego/PinLayout/releases/tag/1.2.4)
11+
#### Change
12+
* Add methods to pin hCenter and vCenter to any other view's edges (including the new hCenter and vCenter edges)
13+
* New methods:
14+
* func hCenter(to edge: HorizontalEdge) -> PinLayout
15+
* func vCenter(to edge: VerticalEdge) -> PinLayout
16+
* New UIView's edges:
17+
* UIView.edge.hCenter
18+
* UIView.edge.vCenter
19+
* Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#80](https://github.com/mirego/PinLayout/pull/80)
20+
1021
## [1.2.3](https://github.com/mirego/PinLayout/releases/tag/1.2.3)
1122
#### Change
1223
* Warnings now display more context information

PinLayout.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "PinLayout"
19-
s.version = "1.2.3"
19+
s.version = "1.2.4"
2020
s.summary = "Fast Swift UIViews layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable."
2121

2222
# This description is used to generate tags and improve search results.

README.md

Lines changed: 85 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -220,26 +220,26 @@ PinLayout can position a view’s edge relative to its superview edges.
220220
The value specifies the top edge distance from the superview's top edge in pixels.
221221
* **`top(_ percent: Percent)`**
222222
The value specifies the top edge distance from the superview's top edge in percentage of its superview's height.
223-
* **`left(_ value: CGFloat)`**
224-
The value specifies the left edge distance from the superview's left edge in pixels.
225-
* **`left(_ percent: Percent)`**
226-
The value specifies the left edge distance from the superview's left edge in percentage of its superview's width.
223+
* **`vCenter(_ value: CGFloat)`**
224+
The value specifies the vertical center distance from the superview's top edge in pixels.
225+
* **`vCenter(_ percent: Percent)`**
226+
The value specifies the vertical center distance from the superview's top edge in percentage of its superview's height.
227227
* **`bottom(_ value: CGFloat)`**
228228
The value specifies the bottom edge **distance from the superview's bottom edge** in pixels.
229229
* **`bottom(_ percent: Percent)`**
230230
The value specifies the bottom edge **distance from the superview's bottom edge** in percentage of its superview's height.
231-
* **`right(_ value: CGFloat)`**
232-
The value specifies the right edge **distance from the superview's right edge** in pixels.
233-
* **`right(_ percent: Percent)`**
234-
The value specifies the right edge **distance from the superview's right edge** in percentage of its superview's width.
231+
* **`left(_ value: CGFloat)`**
232+
The value specifies the left edge distance from the superview's left edge in pixels.
233+
* **`left(_ percent: Percent)`**
234+
The value specifies the left edge distance from the superview's left edge in percentage of its superview's width.
235235
* **`hCenter(_ value: CGFloat)`**
236236
The value specifies the horizontal center distance from the superview's left edge in pixels.
237237
* **`hCenter(_ percent: Percent)`**
238238
The value specifies the horizontal center distance from the superview's left edge in percentage of its superview's width.
239-
* **`vCenter(_ value: CGFloat)`**
240-
The value specifies the vertical center distance from the superview's top edge in pixels.
241-
* **`vCenter(_ percent: Percent)`**
242-
The value specifies the vertical center distance from the superview's top edge in percentage of its superview's height.
239+
* **`right(_ value: CGFloat)`**
240+
The value specifies the right edge **distance from the superview's right edge** in pixels.
241+
* **`right(_ percent: Percent)`**
242+
The value specifies the right edge **distance from the superview's right edge** in percentage of its superview's width.
243243
* **`start(_ value: CGFloat)`**:left_right_arrow:
244244
In LTR direction the value specifies the left edge distance from the superview's left edge in pixels.
245245
In RTL direction the value specifies the right edge distance from the superview's right edge in pixels.
@@ -285,20 +285,20 @@ PinLayout also has a shorter version that pins a view’s edge **directly** on i
285285

286286
* **`top()`**
287287
Position the view top edge directly on its superview top edge. Similar to calling `top(0)`.
288-
* **`left()`**
289-
Position the view left edge directly on its superview left edge. Similar to calling `left(0)`.
288+
* **`vCenter()`**
289+
Position vertically the view's center directly on its superview vertical center. Similar to calling `vCenter(0)`.
290290
* **`bottom()`**
291291
Position the view bottom edge directly on its superview top edge. Similar to calling `bottom(0)`.
292+
* **`left()`**
293+
Position the view left edge directly on its superview left edge. Similar to calling `left(0)`.
294+
* **`hCenter()`**
295+
Position horizontally the view's center directly on its superview horizontal center. Similar to calling `hCenter(0)`.
292296
* **`right()`**
293297
Position the view right edge directly on its superview right edge. Similar to calling `right(0)`.
294298
* **`start()`**:left_right_arrow:
295299
Position the view left edge directly on its superview left edge in LTR direction or right edge directly on its superview right edge in RTL direction. Similar to calling `start(0)`.
296300
* **`end()`**:left_right_arrow:
297301
Position the view right edge directly on its superview right edge in LTR direction or left edge directly on its superview left edge in RTL direction. Similar to calling `end(0)`.
298-
* **`hCenter()`**
299-
Position the view horizontal center directly on its superview horizontal center. Similar to calling `hCenter(superview.frame.width / 2)`.
300-
* **`vCenter()`**
301-
Position the view vertical center directly on its superview vertical center. Similar to calling `hCenter(superview.frame.height / 2)`.
302302

303303
###### Usage examples:
304304
```swift
@@ -319,6 +319,73 @@ This example is similar to the previous example, but pins edges directly on supe
319319

320320
<br/>
321321

322+
## Edges <a name="edges"></a>
323+
324+
### PinLayout UIView’s edges
325+
326+
PinLayout adds edges properties to UIViews. These properties are used to reference other view’s edges.
327+
328+
**PinLayout UIView’s edges**:
329+
330+
* `UIView.edge.top`
331+
* `UIView.edge.vCenter`
332+
* `UIView.edge.bottom`
333+
* `UIView.edge.left`
334+
* `UIView.edge.hCenter`
335+
* `UIView.edge.right`
336+
* `UIView.edge.start`:left_right_arrow:
337+
* `UIView.edge.end`:left_right_arrow:
338+
339+
![](docs/pinlayout-edges.png)
340+
341+
<br/>
342+
343+
### Layout using edges
344+
345+
PinLayout has methods to attach a UIView's edge (top, left, bottom, right, start or end edge) to another view’s edge.
346+
347+
**Methods:**
348+
349+
* **`top(to edge: ViewEdge)`**:
350+
Position the view's top edge directly on another view’s edge (top/vCenter/bottom).
351+
* **`vCenter(to edge: ViewEdge)`**:
352+
Position vertically the view's center directly on another view’s edge (top/vCenter/bottom).
353+
* **`bottom(to edge: ViewEdge)`**:
354+
Position the view's bottom edge directly on another view’s edge (top/vCenter/bottom).
355+
* **`left(to: edge: ViewEdge)`**:
356+
Position the view's left edge directly on another view’s edge (left/hCenter/right).
357+
* **`hCenter(to: edge: ViewEdge)`**:
358+
Position horizontally the view's center directly on another view’s edge (left/hCenter/right).
359+
* **`right(to: edge: ViewEdge)`**:
360+
Position the view's right edge directly on another view’s edge (left/hCenter/right).
361+
* **`start(to: edge: ViewEdge)`**:left_right_arrow:
362+
In LTR direction it position the view's left edge directly on another view’s edge.
363+
In RTL direction it position the view's right edge directly on another view’s edge.
364+
* **`end(to: edge: ViewEdge)`**:left_right_arrow:
365+
In LTR direction it position the view's top edge directly on another view’s edge.
366+
In RTL direction it position the view's bottom edge directly on another view’s edge.
367+
368+
:pushpin: These methods can pin a view’s edge to any other view's edge, even if don't have the same direct superview! It works with any views that have at some point the same ancestor.
369+
370+
###### Usage examples:
371+
```swift
372+
view.pin.left(to: view1.edge.right)
373+
view.pin.left(to: view1.edge.right).top(to: view2.edge.right)
374+
```
375+
376+
###### Example:
377+
Layout using an edge.
378+
379+
The following example will layout the view B left edge on the view A right edge. It only changes the view B left coordinate.
380+
381+
![](docs/example-edges.png)
382+
383+
```swift
384+
viewB.pin.left(to: viewA.edge.right)
385+
```
386+
387+
<br/>
388+
322389
## Anchors <a name="anchors"></a>
323390

324391
### PinLayout UIView’s anchors
@@ -447,59 +514,6 @@ This is equivalent to:
447514

448515
<br/>
449516

450-
## Edges <a name="edges"></a>
451-
452-
### PinLayout UIView’s edges
453-
454-
PinLayout adds edges properties to UIViews. These properties are used to reference other view’s edges.
455-
456-
**PinLayout UIView’s edges**:
457-
458-
* `UIView.edge.top`
459-
* `UIView.edge.left`
460-
* `UIView.edge.bottom`
461-
* `UIView.edge.right`
462-
* `UIView.edge.start`:left_right_arrow:
463-
* `UIView.edge.end`:left_right_arrow:
464-
465-
![](docs/pinlayout-edges.png)
466-
467-
<br/>
468-
469-
### Layout using edges
470-
471-
PinLayout has methods to attach a UIView's edge (top, left, bottom, right, start or end edge) to another view’s edge.
472-
473-
**Methods:**
474-
475-
* `top(to edge: VerticalEdge)`
476-
* `left(to: edge: HorizontalEdge)`
477-
* `bottom(to edge: VerticalEdge)`
478-
* `right(to: edge: HorizontalEdge)`
479-
* `start(to: edge: HorizontalEdge)`:left_right_arrow:
480-
* `end(to: edge: HorizontalEdge)`:left_right_arrow:
481-
482-
:pushpin: These methods can pin a view’s edge to any other view's edge, even if don't have the same direct superview! It works with any views that have at some point the same ancestor.
483-
484-
###### Usage examples:
485-
```swift
486-
view.pin.left(to: view1.edge.right)
487-
view.pin.left(to: view1.edge.right).top(to: view2.edge.right)
488-
```
489-
490-
###### Example:
491-
Layout using an edge.
492-
493-
The following example will layout the view B left edge on the view A right edge. It only changes the view B left coordinate.
494-
495-
![](docs/example-edges.png)
496-
497-
```swift
498-
viewB.pin.left(to: viewA.edge.right)
499-
```
500-
501-
<br/>
502-
503517
## Relative positioning <a name="relative_positioning"></a>
504518

505519
### Layout using edges relative positioning

0 commit comments

Comments
 (0)