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
SwiftLayout helps you write AutoLayout constraints as consisely, Swiftly, and as natively as possible. Constrain `UIView` and `UILayoutGuide`s interchangeably with a familiar syntax named to match their native properties. This library purposefuly minimizes the repetitive code of defining view hierarchies and building constraints while maximizing constraint flexibility via optional parameters.
15
+
SwiftAutoLayout helps you write AutoLayout constraints as consisely, Swiftly, and as natively as possible. Constrain `UIView` and `UILayoutGuide`s interchangeably with a familiar syntax named to match their native properties. This library purposefuly minimizes the repetitive code of defining view hierarchies and building constraints while maximizing constraint flexibility via optional parameters.
16
16
17
-
SwiftLayout is written to match the AutoLayout APIs as closely as possible, only wrapping types where it improves legibility and simplifies amount of written code. This means your knowledge of AutoLayout directly translates to SwiftLayout, with minimal functionality introduced on top. SwiftLayout does not provide any custom closures or syntaxes for defining constraints, and prefers a functional proramming angle to keep things on a minimum number of lines.
17
+
SwiftAutoLayout is written to match the AutoLayout APIs as closely as possible, only wrapping types where it improves legibility and simplifies amount of written code. This means your knowledge of AutoLayout directly translates to SwiftAutoLayout, with minimal functionality introduced on top. SwiftAutoLayout does not provide any custom closures or syntaxes for defining constraints, and prefers a functional proramming angle to keep things on a minimum number of lines.
18
18
19
19
## Usage
20
20
@@ -29,7 +29,7 @@ override func viewDidLoad() {
29
29
30
30
// Create a label
31
31
let label =UILabel()
32
-
label.text="SwiftLayout is neato!"
32
+
label.text="SwiftAutoLayout is neato!"
33
33
34
34
// Constrain its leading and centerY anchors to be equal to our view's respective anchors
35
35
// Because label doesn't yet have a parent, it will become a child of our view
SwiftLayout makes use of optional arguments to provide clean code when the constraint criteria is an `.equal` relationship, has a constant of 0, multiplier of 1, priority of `.required` and should activate the constraint upon creation. To specify custom values, supply the appropriate method with an argument.
71
+
SwiftAutoLayout makes use of optional arguments to provide clean code when the constraint criteria is an `.equal` relationship, has a constant of 0, multiplier of 1, priority of `.required` and should activate the constraint upon creation. To specify custom values, supply the appropriate method with an argument.
SwiftLayout has 3 main methods for creating different constraint builders suited for different tasks.
100
+
SwiftAutoLayout has 3 main methods for creating different constraint builders suited for different tasks.
101
101
102
-
-`constrain(to:)` returns a [`RelationalConstraintBuilder`](./SwiftLayout/RelationalConstraintBuilder.swift) that is useful for embedding a view inside another and creating constraints that match anchors. In uncommon scenarios where you want to define a constraint between two different anchors, use this builder's `xAxis(_:to:)`, `yAxis(_:to:)`, and `dimension(_:to:)` methods.
102
+
-`constrain(to:)` returns a [`RelationalConstraintBuilder`](./SwiftAutoLayout/RelationalConstraintBuilder.swift) that is useful for embedding a view inside another and creating constraints that match anchors. In uncommon scenarios where you want to define a constraint between two different anchors, use this builder's `xAxis(_:to:)`, `yAxis(_:to:)`, and `dimension(_:to:)` methods.
103
103
104
-
-`constrain(after:)` returns a [`DistributiveConstraintBuilder`](./SwiftLayout/DistributiveConstraintBuilder.swift) that has a couple methods for placing this view vertically or horizontally after another. This builder expects its views and layout guides to already have parents.
104
+
-`constrain(after:)` returns a [`DistributiveConstraintBuilder`](./SwiftAutoLayout/DistributiveConstraintBuilder.swift) that has a couple methods for placing this view vertically or horizontally after another. This builder expects its views and layout guides to already have parents.
105
105
106
-
-`constrainSelf()` returns a [`SelfConstraintBuilder`](./SwiftLayout/SelfConstraintBuilder.swift) which is great for constraining your view's width, height, or aspect ratio.
106
+
-`constrainSelf()` returns a [`SelfConstraintBuilder`](./SwiftAutoLayout/SelfConstraintBuilder.swift) which is great for constraining your view's width, height, or aspect ratio.
You can specify constraints that use system spacing for their "constant" in iOS 11 and later. This is accomplished by an extension on `CGFloat` named `.systemSpacing` — which is a special placeholder value SwiftLayout will take into account when creating your constraint. This value has no use outside of SwiftLayout, and does not work with the `constrainSelf()` builder.
139
+
You can specify constraints that use system spacing for their "constant" in iOS 11 and later. This is accomplished by an extension on `CGFloat` named `.systemSpacing` — which is a special placeholder value SwiftAutoLayout will take into account when creating your constraint. This value has no use outside of SwiftAutoLayout, and does not work with the `constrainSelf()` builder.
@@ -161,7 +161,7 @@ label.constrain(to: view).dimension(.width, to: .height)
161
161
162
162
### Note about Left and Right Anchors
163
163
164
-
SwiftLayout does not use left and right anchors. This simplifies x axis anchors usage by disallowing incorrect usage (mixing left and leading) and cleans up autocomplete. [Apple states](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/AnatomyofaConstraint.html) you should use leading and trailing anchors always, and in scenarios where you want your constraints to not be affected by language direction, change your view's [`semanticContentAttribute`](https://developer.apple.com/documentation/uikit/uiview/1622461-semanticcontentattribute).
164
+
SwiftAutoLayout does not use left and right anchors. This simplifies x axis anchors usage by disallowing incorrect usage (mixing left and leading) and cleans up autocomplete. [Apple states](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/AnatomyofaConstraint.html) you should use leading and trailing anchors always, and in scenarios where you want your constraints to not be affected by language direction, change your view's [`semanticContentAttribute`](https://developer.apple.com/documentation/uikit/uiview/1622461-semanticcontentattribute).
165
165
166
166
> Avoid using Left and Right attributes. Use Leading and Trailing instead. This allows the layout to adapt to the view’s reading direction.
167
167
@@ -171,7 +171,7 @@ SwiftLayout does not use left and right anchors. This simplifies x axis anchors
171
171
172
172
### Custom Parents
173
173
174
-
If you have a special scenario where you want a view's parent to not be set when using `constrain(to:)`, just set its parent beforehand. SwiftLayout's goal is to simplify hierarchy generation and ensure a view has a parent when constraints are created, and it will not change a hierarchy once it exists.
174
+
If you have a special scenario where you want a view's parent to not be set when using `constrain(to:)`, just set its parent beforehand. SwiftAutoLayout's goal is to simplify hierarchy generation and ensure a view has a parent when constraints are created, and it will not change a hierarchy once it exists.
175
175
176
176
### Work from the Bottom Up
177
177
@@ -187,7 +187,7 @@ As a reminder, setting a view's [`accessibilityIdentifier`](https://developer.ap
187
187
188
188
### Use Layout Guides!
189
189
190
-
`UILayoutGuide`s are awesome. If you set up your views correctly and use their [`directionalLayoutMargins`](https://developer.apple.com/documentation/uikit/uiview/2865930-directionallayoutmargins) you can write elegant constraints with minimal constants. Since SwiftLayout doesn't use left and right anchors, it's recommended to use [`NSDirectionalEdgeInsets`](https://developer.apple.com/documentation/uikit/nsdirectionaledgeinsets) when setting up your layout guides.
190
+
`UILayoutGuide`s are awesome. If you set up your views correctly and use their [`directionalLayoutMargins`](https://developer.apple.com/documentation/uikit/uiview/2865930-directionallayoutmargins) you can write elegant constraints with minimal constants. Since SwiftAutoLayout doesn't use left and right anchors, it's recommended to use [`NSDirectionalEdgeInsets`](https://developer.apple.com/documentation/uikit/nsdirectionaledgeinsets) when setting up your layout guides.
191
191
192
192
You can also create new layout guides instead of views when you need to simplify view layout.
As of now, SwiftLayout does not support AppKit, but is open to pull requests!
210
+
As of now, SwiftAutoLayout does not support AppKit, but is open to pull requests!
211
211
212
-
SwiftLayout only supports anchors that both `UIView` and `UILayoutGuide` have, so `firstBaselineAnchor` and `lastBaselineAnchor` (which only exist on `UIView`) are not yet supported. Again, pull requests are welcome!
212
+
SwiftAutoLayout only supports anchors that both `UIView` and `UILayoutGuide` have, so `firstBaselineAnchor` and `lastBaselineAnchor` (which only exist on `UIView`) are not yet supported. Again, pull requests are welcome!
213
213
214
214
## Installation
215
215
@@ -218,22 +218,22 @@ SwiftLayout only supports anchors that both `UIView` and `UILayoutGuide` have, s
218
218
Add the following line to your Podfile:
219
219
220
220
````ruby
221
-
pod 'SwiftLayout'
221
+
pod 'SwiftAutoLayout'
222
222
````
223
223
224
224
### Carthage
225
225
226
226
Add the following line to your Cartfile:
227
227
228
228
````ruby
229
-
github "SwiftKickMobile/SwiftLayout"
229
+
github "SwiftKickMobile/SwiftAutoLayout"
230
230
````
231
231
232
232
### Manual
233
233
234
-
1. Put SwiftLayout repo somewhere in your project directory.
235
-
1. In Xcode, add `SwiftLayout.xcodeproj` to your project.
236
-
1. On your app's target, add the SwiftLayout framework:
234
+
1. Put SwiftAutoLayout repo somewhere in your project directory.
235
+
1. In Xcode, add `SwiftAutoLayout.xcodeproj` to your project.
236
+
1. On your app's target, add the SwiftAutoLayout framework:
237
237
1. as an embedded binary on the General tab.
238
238
1. as a target dependency on the Build Phases tab.
239
239
@@ -242,4 +242,4 @@ We build high quality apps! [Get in touch](http://www.swiftkickmobile.com) if yo
242
242
243
243
## License
244
244
245
-
SwiftLayout is distributed under the MIT license. [See LICENSE](./LICENSE.md) for details.
245
+
SwiftAutoLayout is distributed under the MIT license. [See LICENSE](./LICENSE.md) for details.
0 commit comments