|
|
@@ -84,6 +84,9 @@ public protocol ConstraintBuilderOffsetable: ConstraintBuilderMultipliable {
|
|
|
func offset(amount: CGSize) -> ConstraintBuilderMultipliable
|
|
|
func offset(amount: EdgeInsets) -> ConstraintBuilderMultipliable
|
|
|
|
|
|
+ func inset(amount: EdgeInsets) -> ConstraintBuilderMultipliable
|
|
|
+
|
|
|
+ @availability(*, deprecated=0.10.0, renamed="inset")
|
|
|
func insets(amount: EdgeInsets) -> ConstraintBuilderMultipliable
|
|
|
}
|
|
|
|
|
|
@@ -420,12 +423,15 @@ final internal class ConstraintBuilder: Constraint, ConstraintBuilderExtendable,
|
|
|
return self
|
|
|
}
|
|
|
|
|
|
- // MARK: insets
|
|
|
+ // MARK: inset
|
|
|
|
|
|
- func insets(amount: EdgeInsets) -> ConstraintBuilderMultipliable {
|
|
|
+ func inset(amount: EdgeInsets) -> ConstraintBuilderMultipliable {
|
|
|
self.constant = EdgeInsets(top: amount.top, left: amount.left, bottom: -amount.bottom, right: -amount.right)
|
|
|
return self
|
|
|
}
|
|
|
+ func insets(amount: EdgeInsets) -> ConstraintBuilderMultipliable {
|
|
|
+ return self.inset(amount)
|
|
|
+ }
|
|
|
|
|
|
// MARK: Constraint
|
|
|
|
|
|
@@ -764,8 +770,8 @@ private extension NSLayoutAttribute {
|
|
|
case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return insets.top
|
|
|
case .Right, .RightMargin: return insets.right
|
|
|
case .Bottom, .BottomMargin: return insets.bottom
|
|
|
- case .Leading, .LeadingMargin: return insets.left
|
|
|
- case .Trailing, .TrailingMargin: return insets.right
|
|
|
+ case .Leading, .LeadingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.left : -insets.right
|
|
|
+ case .Trailing, .TrailingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.right : -insets.left
|
|
|
case .Width, .Height, .NotAnAttribute: return CGFloat(0)
|
|
|
}
|
|
|
#else
|
|
|
@@ -774,8 +780,8 @@ private extension NSLayoutAttribute {
|
|
|
case .Top, .CenterY, .Baseline: return insets.top
|
|
|
case .Right: return insets.right
|
|
|
case .Bottom: return insets.bottom
|
|
|
- case .Leading: return insets.left
|
|
|
- case .Trailing: return insets.right
|
|
|
+ case .Leading, .LeadingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.left : -insets.right
|
|
|
+ case .Trailing, .TrailingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.right : -insets.left
|
|
|
case .Width, .Height, .NotAnAttribute: return CGFloat(0)
|
|
|
}
|
|
|
#endif
|