You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I invite you to extend this comparison. First, the example code itself could be extended and, second, it would be interesting how it looks written with the native API, SnapKit and Anchorage ...
Copy file name to clipboardExpand all lines: README.md
+19-62Lines changed: 19 additions & 62 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,25 +19,22 @@ GetLaid is a lean framework for laying out complex UIs through short readable co
19
19
20
20
### Features
21
21
22
-
GetLaid has some advantages even over classic simple frameworks like [PureLayout](https://github.com/PureLayout/PureLayout):
23
-
24
22
*:white_check_mark: Readability
25
-
- Functions are of the principle form "[constrained aspect] constrain to [constraining aspect]"
26
-
- This semantic naming makes auto completion more valuable, as it quickly and meaningfully narrows down the available options.
27
-
- All functions have the prefix `constrain` which expresses best what they really do: They constrain some attributes and return the resulting constraints.
28
-
- PureLayout is much more convoluted with its 6 different function prefixes: `autoPin`, `autoAlign`, `autoMatch`, `autoCenter`, `autoSet` and `autoConstrain`.
23
+
- The syntax is close to natural language instead of technically fancy.
24
+
- All constraining has the form `source.constrain(to: target)`.
25
+
- The operator `>>` can add further clarity: `source >> target`
29
26
*:white_check_mark: Brevity
30
-
-Shorter lines of code with less function arguments (see comparison below)
-Works on [UILayoutGuide](https://developer.apple.com/documentation/uikit/uilayoutguide) and [NSLayoutGuide](https://developer.apple.com/documentation/appkit/nslayoutguide) just as well as on views
41
38
*:white_check_mark: Modern Swift Under the Hood
42
39
- No Objective-c
43
40
- Extensive use of [Layout Anchors](https://developer.apple.com/documentation/uikit/nslayoutanchor)
@@ -50,13 +47,13 @@ Well, that [would be insane](https://www.flowtoolz.com/2019/09/27/the-reasons-fo
50
47
51
48
Programmatic AutoLayout without any such frameworks was never hard. It's all about creating objects of `NSLayoutConstraint`, which has only one [powerful initializer](https://developer.apple.com/documentation/uikit/nslayoutconstraint/1526954-init).
52
49
53
-
Since iOS 9.0 and macOS 10.11, we also have `NSLayoutAnchor`, which adds a native abstraction layer on top of `NSLayoutConstraint`, further reducing the need for any AutoLayout wrappers at all.
50
+
Since iOS/tvOS 9.0 and macOS 10.11, we also have [`NSLayoutAnchor`](https://developer.apple.com/documentation/uikit/nslayoutanchor), which adds a native abstraction layer on top of `NSLayoutConstraint`, further reducing the need for any AutoLayout wrappers at all.
54
51
55
52
At this point, all an AutoLayout wrapper can do is to make code even more meaningful, readable and succinct at the point of use. GetLaid does exactly that.
56
53
57
54
### Why Not Other AutoLayout Wrappers?
58
55
59
-
Modern AutoLayout wrappers like [SnapKit](https://github.com/SnapKit/SnapKit) are almost too clever for the simple task at hand. A SnapKit example:
56
+
Modern AutoLayout wrappers like [SnapKit](https://github.com/SnapKit/SnapKit) are almost too clever for the simple task at hand. The first example from the SnapKit README:
If you can spare fancyness but appreciate readability, GetLaid might be for you.
121
80
81
+
Here is also a [richer comparison](Documentation/comparison_to_alternatives.md) of how layout code looks with GetLaid and its alternatives.
82
+
122
83
## Install
123
84
124
85
With the [**Swift Package Manager**](https://github.com/apple/swift-package-manager/tree/master/Documentation#swift-package-manager), you can just add the GetLaid package [via Xcode](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) (11+).
Remember that these constants are not hardcoded but dynamically calculated on the actual user device, so they are absolutely true to what Apple intents for sibling gaps and parent insets, on any system and on any iOS/tvOS version. But also note that these two values do not capture the system spacing magic that `NSLayoutAnchor` offers in conjunction with baselines and font sizes and possibly in other contexts.
0 commit comments