@@ -18,6 +18,10 @@ A declarative, expressive and efficient way to lay out your views.
18
18
** Flexible** | Write the same constraints you already do, using whatever autolayout constraint DSL you prefer.
19
19
** Small** | Small and readable Swift 4 codebase.
20
20
21
+ [ Usage] ( #usage ) | [ Updating to a new layout] ( #updating-to-a-new-layout ) | [ Installation] ( #installation ) | [ Requirements] ( #requirements )
22
+ | [ Building on top of DeclarativeLayout] ( #building-on-top-of-declarativelayout ) |
23
+ [ License] ( #license )
24
+
21
25
---
22
26
23
27
## Usage
@@ -44,7 +48,9 @@ viewLayout.updateLayoutTo { (component) in
44
48
}
45
49
```
46
50
47
- Use the layout components to define new views that should be in the hierarchy, as well as the constraints that should be active.
51
+ Use the layout components to define new views that should be in the hierarchy,
52
+ as well as the constraints that should be active (Note: All constraints passed
53
+ to ` activate(_:) ` method should not be active).
48
54
49
55
Here is an example:
50
56
@@ -57,6 +63,7 @@ viewLayout.updateLayoutTo { (component) in
57
63
component.view .topAnchor .constraint (equalTo : component.superview .safeAreaLayoutGuide .topAnchor ,
58
64
constant : 35 ),
59
65
])
66
+
60
67
component.view .axis = .vertical
61
68
component.addArrangedView (self .redView ) { (component) in
62
69
component.activate ([
@@ -99,7 +106,9 @@ viewLayout.updateLayoutTo { (component) in
99
106
100
107
That will give you a view looking like this:
101
108
102
- <img src =" /Resources/layout1.png " width =400 />
109
+ <img src =" /Resources/layout1.png " height =500 />
110
+
111
+ ## Updating to a new layout
103
112
104
113
If you want to update to a new layout, just call the ` updateLayoutTo ` method
105
114
again, defining what your layout should be. The framework will take care of
@@ -108,9 +117,9 @@ modifying constraints.
108
117
109
118
As an example, let's randomly order these views, the spacing inbetween them and
110
119
their height, re-updating the layout in this way every few seconds. The result
111
- will look like this:
120
+ will look something like this:
112
121
113
- ![ Video animating change ] ( /Resources/animateChange.gif )
122
+ < img src = " /Resources/animateChange.gif " height = 500 />
114
123
115
124
``` swift
116
125
let views = [redView,
@@ -128,6 +137,7 @@ viewLayout.updateLayoutTo { (component) in
128
137
component.view .topAnchor .constraint (equalTo : component.superview .safeAreaLayoutGuide .topAnchor ,
129
138
constant : 35 ),
130
139
])
140
+
131
141
component.view .axis = .vertical
132
142
for view in views.shuffled () {
133
143
component.addArrangedView (view) { (component) in
@@ -154,7 +164,6 @@ pod "DeclarativeLayout"
154
164
## Requirements
155
165
156
166
* iOS 9.0 or later
157
- * Xcode 9 or later
158
167
* Supports Swift 4.2
159
168
160
169
## Building on top of DeclarativeLayout
0 commit comments