iwill 8 жил өмнө
parent
commit
dade6659b9

+ 6 - 0
Masonry/MASCompositeConstraint.m

@@ -129,6 +129,12 @@
     }
 }
 
+- (void)setInset:(CGFloat)inset {
+    for (MASConstraint *constraint in self.childConstraints) {
+        constraint.inset = inset;
+    }
+}
+
 - (void)setOffset:(CGFloat)offset {
     for (MASConstraint *constraint in self.childConstraints) {
         constraint.offset = offset;

+ 14 - 0
Masonry/MASConstraint.h

@@ -24,6 +24,13 @@
  */
 - (MASConstraint * (^)(MASEdgeInsets insets))insets;
 
+/**
+ *	Modifies the NSLayoutConstraint constant,
+ *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
+ *  NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
+ */
+- (MASConstraint * (^)(CGFloat inset))inset;
+
 /**
  *	Modifies the NSLayoutConstraint constant,
  *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
@@ -163,6 +170,13 @@
  */
 - (void)setInsets:(MASEdgeInsets)insets;
 
+/**
+ *	Modifies the NSLayoutConstraint constant,
+ *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
+ *  NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
+ */
+- (void)setInset:(CGFloat)inset;
+
 /**
  *	Modifies the NSLayoutConstraint constant,
  *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following

+ 9 - 0
Masonry/MASConstraint.m

@@ -92,6 +92,13 @@
     };
 }
 
+- (MASConstraint * (^)(CGFloat))inset {
+    return ^id(CGFloat inset){
+        self.inset = inset;
+        return self;
+    };
+}
+
 - (MASConstraint * (^)(CGSize))sizeOffset {
     return ^id(CGSize offset) {
         self.sizeOffset = offset;
@@ -269,6 +276,8 @@
 
 - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); }
 
+- (void)setInset:(CGFloat __unused)inset { MASMethodNotImplemented(); }
+
 - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); }
 
 - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); }

+ 4 - 0
Masonry/MASViewConstraint.m

@@ -254,6 +254,10 @@ static char kInstalledConstraintsKey;
     }
 }
 
+- (void)setInset:(CGFloat)inset {
+    [self setInsets:(MASEdgeInsets){.top = inset, .left = inset, .bottom = inset, .right = inset}];
+}
+
 - (void)setOffset:(CGFloat)offset {
     self.layoutConstant = offset;
 }