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: Sources/QuickConstraint/View+AutoLayout.swift
+17-2Lines changed: 17 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -216,9 +216,9 @@ public extension View {
216
216
return constraints
217
217
}
218
218
219
-
/// Creates constraints for width/height dimensions with specified size.
219
+
/// Creates constraints for width/height/size dimensions with specified size.
220
220
/// - Parameters:
221
-
/// - dimension: Dimension type to be used for determining which constraints to generate. Use `all` to generate width and height constraints simultaneously.
221
+
/// - dimension: Dimension type to be used for determining which constraints to generate. Use `size` to generate width and height constraints simultaneously.
222
222
/// - value: Size of set dimensions.
223
223
/// - Returns: Generated active constraints.
224
224
@inline(__always)
@@ -231,6 +231,21 @@ public extension View {
231
231
LayoutConstraint.activate(constraints)
232
232
return constraints
233
233
}
234
+
235
+
/// Creates constraints for width/height/size dimensions based on another view's width/height/size.
236
+
/// - Parameters:
237
+
/// - dimension: Dimension type to be used for determining which dimension constraints to generate. Use `size` to generate width and height constraints simultaneously..
238
+
/// - view: Parent of sibling view to use as a reference for constraints.
239
+
/// - Returns: Generated active constraints.
240
+
@discardableResult
241
+
func set(_ dimension:Dimension, to view:View)->[LayoutConstraint]{
242
+
translatesAutoresizingMaskIntoConstraints =false
243
+
varconstraints=[LayoutConstraint]()
244
+
if dimension.isWidth { constraints.append(widthAnchor.constraint(equalTo: view.widthAnchor))}
245
+
if dimension.isHeight { constraints.append(heightAnchor.constraint(equalTo: view.heightAnchor))}
246
+
LayoutConstraint.activate(constraints)
247
+
return constraints
248
+
}
234
249
235
250
/// Creates constraints based on center x and y axis.
0 commit comments