From 32f1ae7f7df9022a1dfeacc26ce95464c9987387 Mon Sep 17 00:00:00 2001 From: Per Ejeklint Date: Fri, 13 Oct 2017 11:31:28 +0200 Subject: [PATCH 1/9] Update docs.md (#461) I think top should be equal to safeAreaLayoutguide.snp.top --- docs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs.md b/docs.md index cf9dd1a..1d2fb6a 100644 --- a/docs.md +++ b/docs.md @@ -341,7 +341,7 @@ class MyViewController: UIVewController { self.view.addSubview(tableView) tableView.snp.makeConstraints { (make) -> Void in - make.top.equalTo(self.safeAreaLayoutGuide.snp.bottom) + make.top.equalTo(self.safeAreaLayoutGuide.snp.top) } } @@ -350,4 +350,4 @@ class MyViewController: UIVewController {

-
\ No newline at end of file +
From a0aaba1f387286d92cc23e189d64337f3d46826b Mon Sep 17 00:00:00 2001 From: Benjamin Chrobot Date: Fri, 13 Oct 2017 05:33:49 -0400 Subject: [PATCH 2/9] Added documentation for priority shortcuts. (#468) --- docs.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs.md b/docs.md index 1d2fb6a..154c7a0 100644 --- a/docs.md +++ b/docs.md @@ -186,6 +186,12 @@ Priorities are can be tacked on to the end of a constraint chain like so: make.top.equalTo(label.snp.top).priority(600) ``` +You may also use priority shortcuts: `.low`, `.medium`, `.high`, `.required`. + +```swift +make.top.equalTo(label.snp.top).priority(.medium) +``` + ### Composition, composition, composition SnapKit also gives you a few convenience methods to create multiple constraints at the same time. From dd786e32c9961a53948812a31d8c8a003f0fa3cd Mon Sep 17 00:00:00 2001 From: beltex Date: Sat, 19 May 2018 00:49:58 -0400 Subject: [PATCH 3/9] Update safeAreaLayoutGuide usage - now a property of UIView (#473) * https://github.com/SnapKit/SnapKit/issues/448#issuecomment-330114911 * https://developer.apple.com/documentation/uikit/uiview/2891102-safearealayoutguide --- docs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs.md b/docs.md index 154c7a0..50d7148 100644 --- a/docs.md +++ b/docs.md @@ -331,7 +331,7 @@ class MyViewController: UIVewController { ``` -### Snap view to safe layout guide +### Snap view to safeAreaLayoutGuide Just like `topLayoutGuide` and `bottomLayoutGuide` using iPhone X's new `safeAreaLayoutGuide` is easy: @@ -347,7 +347,7 @@ class MyViewController: UIVewController { self.view.addSubview(tableView) tableView.snp.makeConstraints { (make) -> Void in - make.top.equalTo(self.safeAreaLayoutGuide.snp.top) + make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top) } } From 5a012e926afef8b90082c5ec875c494140f2d042 Mon Sep 17 00:00:00 2001 From: Tyler Alves Date: Fri, 18 May 2018 21:50:23 -0700 Subject: [PATCH 4/9] Add labeled method to docs (#485) The labeled feature is amazing for debugging, but is not obviously documented. --- docs.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs.md b/docs.md index 50d7148..9863df1 100644 --- a/docs.md +++ b/docs.md @@ -180,7 +180,7 @@ make.left.equalTo(view).offset(UIEdgeInsets(top: 10, left: 0, bottom: 10, right: > `.priority` allows you to specify an exact priority -Priorities are can be tacked on to the end of a constraint chain like so: +Priorities can be tacked on to the end of a constraint chain like so: ```swift make.top.equalTo(label.snp.top).priority(600) @@ -354,6 +354,24 @@ class MyViewController: UIVewController { } ``` +### Debug with ease +> `.labeled` allows you to specify constraint labels for debug logs + +Labels can be tacked on to the end of a constraint chain like so: + +```swift +button.snp.makeConstraints { (make) -> Void in + make.top.equalTo(otherView).labeled("buttonViewTopConstraint") +} +``` + +Resulting `Unable to simultaneously satisfy constraints.` logs will use constraint labels to clearly identify which constraints need attention: + +``` +"" +``` +


From e5bc2ced4ba6117968ffec45ecb3b2e65207eca2 Mon Sep 17 00:00:00 2001 From: Brad Patras Date: Thu, 18 Feb 2021 15:17:50 -0600 Subject: [PATCH 5/9] Update docs to reflect current api. (#701) docs still used deprecated 'uninstall()' --- docs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs.md b/docs.md index 9863df1..c231a2b 100644 --- a/docs.md +++ b/docs.md @@ -257,7 +257,7 @@ view1.snp.makeConstraints { (make) -> Void in ... // then later you can call -self.topConstraint.uninstall() +self.topConstraint.deactivate() // or if you want to update the constraint self.topConstraint.updateOffset(5) From bfbdca7441a967d6b11820c3e2b79ddd9b1b7966 Mon Sep 17 00:00:00 2001 From: Glenn Date: Tue, 8 Jun 2021 15:41:14 +0900 Subject: [PATCH 6/9] Update docs to reflect current api. (#720) --- docs.md | 60 ++++++++++++++++----------------------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/docs.md b/docs.md index c231a2b..0f26a15 100644 --- a/docs.md +++ b/docs.md @@ -96,7 +96,7 @@ let box = UIView() superview.addSubview(box) box.snp.makeConstraints { (make) -> Void in - make.edges.equalTo(superview).inset(UIEdgeInsetsMake(20, 20, 20, 20)) + make.edges.equalTo(superview).inset(UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)) } ``` @@ -104,15 +104,15 @@ Not only does this greatly shorten and increase the readability of constraints S - Determining the best common superview to install the constraints on. - Keeping track of the constrainted installed so they can easily be removed later. -- Ensuring `setTranslatesAutoresizingMaskIntoConstraints(false)` is called on all appropriate views. +- Ensuring `translatesAutoresizingMaskIntoConstraints = false` is called on all appropriate views. ### Not all things are created equal -> `.equalTo` equivalent to **NSLayoutRelation.Equal** +> `.equalTo` equivalent to **NSLayoutConstraint.Relation.equal** -> `.lessThanOrEqualTo` equivalent to **NSLayoutRelation.LessThanOrEqual** +> `.lessThanOrEqualTo` equivalent to **NSLayoutConstraint.Relation.lessThanOrEqual** -> `.greaterThanOrEqualTo` equivalent to **NSLayoutRelation.GreaterThanOrEqual** +> `.greaterThanOrEqualTo` equivalent to **NSLayoutConstraint.Relation.greaterThanOrEqual** These three equality constraints accept one argument which can be any of the following: @@ -124,17 +124,17 @@ make.centerX.lessThanOrEqualTo(view2.snp.left) ViewAttribute | NSLayoutAttribute ------------------------- | -------------------------- -view.snp.left | NSLayoutAttribute.left -view.snp.right | NSLayoutAttribute.right -view.snp.top | NSLayoutAttribute.top -view.snp.bottom | NSLayoutAttribute.bottom -view.snp.leading | NSLayoutAttribute.leading -view.snp.trailing | NSLayoutAttribute.trailing -view.snp.width | NSLayoutAttribute.width -view.snp.height | NSLayoutAttribute.height -view.snp.centerX | NSLayoutAttribute.centerX -view.snp.centerY | NSLayoutAttribute.centerY -view.snp.lastBaseline | NSLayoutAttribute.lastBaseline +view.snp.left | NSLayoutConstraint.Attribute.left +view.snp.right | NSLayoutConstraint.Attribute.right +view.snp.top | NSLayoutConstraint.Attribute.top +view.snp.bottom | NSLayoutConstraint.Attribute.bottom +view.snp.leading | NSLayoutConstraint.Attribute.leading +view.snp.trailing | NSLayoutConstraint.Attribute.trailing +view.snp.width | NSLayoutConstraint.Attribute.width +view.snp.height | NSLayoutConstraint.Attribute.height +view.snp.centerX | NSLayoutConstraint.Attribute.centerX +view.snp.centerY | NSLayoutConstraint.Attribute.centerY +view.snp.lastBaseline | NSLayoutConstraint.Attribute.lastBaseline #### 2. UIView/NSView @@ -304,36 +304,10 @@ func changeButtonPosition() { } ``` -### Snap view to topLayoutGuide and bottomLayoutGuide - - `topLayoutGuide.snp.bottom` is similar to `topLayoutGuide.bottomAnchor` and you can also use `bottomLayoutGuide.snp.top` to align view on top of UITabBar. - -```swift -import SnapKit - -class MyViewController: UIVewController { - - lazy var tableView = UITableView() - - override func viewDidLoad() { - super.viewDidLoad() - - self.view.addSubview(tableView) - tableView.snp.makeConstraints { (make) -> Void in - make.top.equalTo(self.topLayoutGuide.snp.bottom) - make.left.equalTo(view) - make.right.equalTo(view) - make.bottom.equalTo(self.bottomLayoutGuide.snp.top) - } - } - -} -``` - ### Snap view to safeAreaLayoutGuide -Just like `topLayoutGuide` and `bottomLayoutGuide` using iPhone X's new `safeAreaLayoutGuide` is easy: + `topLayoutGuide` and `bottomLayoutGuide` were deprecated in `iOS 11`. Use `safeAreaLayoutGuide`: ```swift import SnapKit From 994239e4df73556523c5dd2c76dd7c78f42c3193 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Wed, 13 Apr 2022 15:57:24 +1200 Subject: [PATCH 7/9] Delete CNAME --- CNAME | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CNAME diff --git a/CNAME b/CNAME deleted file mode 100644 index daea621..0000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -snapkit.io \ No newline at end of file From 9d49390543eee011bd3847899075e27ca426ebcb Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Wed, 13 Apr 2022 15:58:29 +1200 Subject: [PATCH 8/9] Create CNAME --- CNAME | 1 + 1 file changed, 1 insertion(+) create mode 100644 CNAME diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..daea621 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +snapkit.io \ No newline at end of file From 534d75d22ee919ac58416fb5b8ebe5361ecd6ef1 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Wed, 13 Apr 2022 15:58:47 +1200 Subject: [PATCH 9/9] Delete CNAME --- CNAME | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CNAME diff --git a/CNAME b/CNAME deleted file mode 100644 index daea621..0000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -snapkit.io \ No newline at end of file