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
Copy file name to clipboardExpand all lines: AnchorKit/Source/Anchorable+Constraints.swift
+28-37Lines changed: 28 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -118,78 +118,69 @@ extension Anchorable {
118
118
119
119
/**
120
120
Constrains the edges of the current item to another item by creating and activating the leading, trailing, top, and bottom constraints.
121
-
- parameter relation: The relation for all of the constraints. If you want to use `.equal`, you can use `constrainEdges(to:priority:)` instead.
121
+
- parameter relation: The relation for all of the constraints. Default is `.equal`.
122
122
- parameter item: The item to which to constrain.
123
123
- parameter priority: The layout priority to set for the constraints. Default is `.required`.
124
124
- returns: The newly created and activated constraints for the leading, trailing, top, and bottom anchors.
125
125
*/
126
126
@discardableResult
127
-
publicfunc constrainEdges<AnchorableType:Anchorable>(_ relation:Relation, to item:AnchorableType, priority:LayoutPriority=.required)->[NSLayoutConstraint]{
127
+
publicfunc constrainEdges<AnchorableType:Anchorable>(_ relation:Relation=.equal, to item:AnchorableType, priority:LayoutPriority=.required)->[NSLayoutConstraint]{
128
128
returnconstrain(.leading,.trailing,.top,.bottom, relation: relation, to: item, priority: priority)
129
129
}
130
130
131
-
/**
132
-
Constrains the edges of the current item to another item by creating and activating the leading, trailing, top, and bottom constraints. If you want to use this with a relation, use `constrainEdges(_:to:priority:)`.
133
-
- parameter item: The item to which to constrain.
134
-
- parameter priority: The layout priority to set for the constraints. Default is `.required`.
135
-
- returns: The newly created and activated constraints for the leading, trailing, top, and bottom anchors.
returnconstrainEdges(.equal, to: item, priority: priority)
140
-
}
141
-
142
131
// MARK: - Center Constraints
143
132
144
-
/**
145
-
Convenience method for centering the current item in another item by creating the centerX and centerY constraints. If you want to use this with a relation, use `constrainCenter(_:to:priority:)`.
146
-
- parameter item: The item in which to center the current item.
147
-
- parameter priority: The layout priority to set for the constraints. Default is `.required`.
148
-
- returns: The newly created and activated constraints for the centerX and centerY anchors.
@@ -159,6 +160,10 @@ Constrain an anchor of an item to a constant. This is is especially useful (and
159
160
````swift
160
161
myView.constrain(.height, toConstant: 200)
161
162
myBoxView.constrain(.width, .height, toConstant: 50) // Creates a box
163
+
164
+
// Even easier:
165
+
myView.constrainHeight(to: 42)
166
+
myView.constrainWidth(to: 60)
162
167
````
163
168
164
169
Calling this method with a single anchor will implicitly return `NSLayoutConstraint`. Otherwise, the return type is `[NSLayoutConstraint]`. The full signatures of these methods are shown below.
0 commit comments