|
@@ -60,8 +60,8 @@ internal extension UIView {
|
|
|
return constraintAlignTopTo(view, paddingTop: 0.0)
|
|
|
}
|
|
|
|
|
|
- func constraintAlignTopTo(_ view: UIView, paddingTop: CGFloat = 0.0) -> NSLayoutConstraint {
|
|
|
- return NSLayoutConstraint(
|
|
|
+ func constraintAlignTopTo(_ view: UIView, paddingTop: CGFloat = 0.0, priority: UILayoutPriority? = .none) -> NSLayoutConstraint {
|
|
|
+ let constraint = NSLayoutConstraint(
|
|
|
item: self,
|
|
|
attribute: .top,
|
|
|
relatedBy: .equal,
|
|
@@ -69,10 +69,14 @@ internal extension UIView {
|
|
|
attribute: .top,
|
|
|
multiplier: 1.0,
|
|
|
constant: paddingTop)
|
|
|
+ if let priority = priority {
|
|
|
+ constraint.priority = priority
|
|
|
+ }
|
|
|
+ return constraint
|
|
|
}
|
|
|
|
|
|
- func constraintAlignBottomTo(_ view: UIView, paddingBottom: CGFloat = 0.0) -> NSLayoutConstraint {
|
|
|
- return NSLayoutConstraint(
|
|
|
+ func constraintAlignBottomTo(_ view: UIView, paddingBottom: CGFloat = 0.0, priority: UILayoutPriority? = .none) -> NSLayoutConstraint {
|
|
|
+ let constraint = NSLayoutConstraint(
|
|
|
item: self,
|
|
|
attribute: .bottom,
|
|
|
relatedBy: .equal,
|
|
@@ -80,10 +84,14 @@ internal extension UIView {
|
|
|
attribute: .bottom,
|
|
|
multiplier: 1.0,
|
|
|
constant: -paddingBottom)
|
|
|
+ if let priority = priority {
|
|
|
+ constraint.priority = priority
|
|
|
+ }
|
|
|
+ return constraint
|
|
|
}
|
|
|
|
|
|
- func constraintAlignLeadingTo(_ view: UIView, paddingLeading: CGFloat = 0.0) -> NSLayoutConstraint {
|
|
|
- return NSLayoutConstraint(
|
|
|
+ func constraintAlignLeadingTo(_ view: UIView, paddingLeading: CGFloat = 0.0, priority: UILayoutPriority? = .none) -> NSLayoutConstraint {
|
|
|
+ let constraint = NSLayoutConstraint(
|
|
|
item: self,
|
|
|
attribute: .leading,
|
|
|
relatedBy: .equal,
|
|
@@ -91,10 +99,14 @@ internal extension UIView {
|
|
|
attribute: .leading,
|
|
|
multiplier: 1.0,
|
|
|
constant: paddingLeading)
|
|
|
+ if let priority = priority {
|
|
|
+ constraint.priority = priority
|
|
|
+ }
|
|
|
+ return constraint
|
|
|
}
|
|
|
|
|
|
- func constraintAlignTrailingTo(_ view: UIView, paddingTrailing: CGFloat = 0.0) -> NSLayoutConstraint {
|
|
|
- return NSLayoutConstraint(
|
|
|
+ func constraintAlignTrailingTo(_ view: UIView, paddingTrailing: CGFloat = 0.0, priority: UILayoutPriority? = .none) -> NSLayoutConstraint {
|
|
|
+ let constraint = NSLayoutConstraint(
|
|
|
item: self,
|
|
|
attribute: .trailing,
|
|
|
relatedBy: .equal,
|
|
@@ -102,10 +114,14 @@ internal extension UIView {
|
|
|
attribute: .trailing,
|
|
|
multiplier: 1.0,
|
|
|
constant: -paddingTrailing)
|
|
|
+ if let priority = priority {
|
|
|
+ constraint.priority = priority
|
|
|
+ }
|
|
|
+ return constraint
|
|
|
}
|
|
|
|
|
|
- func constraintToBottomOf(_ view: UIView, paddingTop: CGFloat = 0.0) -> NSLayoutConstraint {
|
|
|
- return NSLayoutConstraint(
|
|
|
+ func constraintToBottomOf(_ view: UIView, paddingTop: CGFloat = 0.0, priority: UILayoutPriority? = .none) -> NSLayoutConstraint {
|
|
|
+ let constraint = NSLayoutConstraint(
|
|
|
item: self,
|
|
|
attribute: .top,
|
|
|
relatedBy: .equal,
|
|
@@ -113,10 +129,14 @@ internal extension UIView {
|
|
|
attribute: .bottom,
|
|
|
multiplier: 1.0,
|
|
|
constant: paddingTop)
|
|
|
+ if let priority = priority {
|
|
|
+ constraint.priority = priority
|
|
|
+ }
|
|
|
+ return constraint
|
|
|
}
|
|
|
|
|
|
- func constraintToTrailingOf(_ view: UIView, paddingLeading: CGFloat = 0.0) -> NSLayoutConstraint {
|
|
|
- return NSLayoutConstraint(
|
|
|
+ func constraintToTrailingOf(_ view: UIView, paddingLeading: CGFloat = 0.0, priority: UILayoutPriority? = .none) -> NSLayoutConstraint {
|
|
|
+ let constraint = NSLayoutConstraint(
|
|
|
item: self,
|
|
|
attribute: .leading,
|
|
|
relatedBy: .equal,
|
|
@@ -124,35 +144,55 @@ internal extension UIView {
|
|
|
attribute: .trailing,
|
|
|
multiplier: 1.0,
|
|
|
constant: paddingLeading)
|
|
|
+ if let priority = priority {
|
|
|
+ constraint.priority = priority
|
|
|
+ }
|
|
|
+ return constraint
|
|
|
}
|
|
|
|
|
|
|
|
|
- func constraintCenterXTo(_ view: UIView, paddingX: CGFloat = 0.0) -> NSLayoutConstraint {
|
|
|
- return NSLayoutConstraint(item: self,
|
|
|
+ func constraintCenterXTo(_ view: UIView, paddingX: CGFloat = 0.0, priority: UILayoutPriority? = .none) -> NSLayoutConstraint {
|
|
|
+ let constraint = NSLayoutConstraint(item: self,
|
|
|
attribute: .centerX,
|
|
|
relatedBy: .equal,
|
|
|
toItem: view,
|
|
|
attribute: .centerX,
|
|
|
multiplier: 1.0,
|
|
|
constant: paddingX)
|
|
|
+ if let priority = priority {
|
|
|
+ constraint.priority = priority
|
|
|
+ }
|
|
|
+ return constraint
|
|
|
}
|
|
|
|
|
|
- func constraintCenterYTo(_ view: UIView, paddingY: CGFloat = 0.0) -> NSLayoutConstraint {
|
|
|
- return NSLayoutConstraint(item: self,
|
|
|
+ func constraintCenterYTo(_ view: UIView, paddingY: CGFloat = 0.0, priority: UILayoutPriority? = .none) -> NSLayoutConstraint {
|
|
|
+ let constraint = NSLayoutConstraint(item: self,
|
|
|
attribute: .centerY,
|
|
|
relatedBy: .equal,
|
|
|
toItem: view,
|
|
|
attribute: .centerY,
|
|
|
multiplier: 1.0,
|
|
|
constant: paddingY)
|
|
|
+ if let priority = priority {
|
|
|
+ constraint.priority = priority
|
|
|
+ }
|
|
|
+ return constraint
|
|
|
}
|
|
|
|
|
|
- func constraintHeightTo(_ height: CGFloat) -> NSLayoutConstraint {
|
|
|
- return heightAnchor.constraint(equalToConstant: height)
|
|
|
+ func constraintHeightTo(_ height: CGFloat, priority: UILayoutPriority? = .none) -> NSLayoutConstraint {
|
|
|
+ let constraint = heightAnchor.constraint(equalToConstant: height)
|
|
|
+ if let priority = priority {
|
|
|
+ constraint.priority = priority
|
|
|
+ }
|
|
|
+ return constraint
|
|
|
}
|
|
|
|
|
|
- func constraintWidthTo(_ width: CGFloat) -> NSLayoutConstraint {
|
|
|
- return widthAnchor.constraint(equalToConstant: width)
|
|
|
+ func constraintWidthTo(_ width: CGFloat, priority: UILayoutPriority? = .none) -> NSLayoutConstraint {
|
|
|
+ let constraint = widthAnchor.constraint(equalToConstant: width)
|
|
|
+ if let priority = priority {
|
|
|
+ constraint.priority = priority
|
|
|
+ }
|
|
|
+ return constraint
|
|
|
}
|
|
|
|
|
|
func fillSuperview() {
|