Browse Source

Merge pull request #168 from montehurd/leadingTrailingInsets

Added support and tests for leading and trailing insets.
Jonas Budelmann 10 years ago
parent
commit
008e545b37
2 changed files with 10 additions and 0 deletions
  1. 2 0
      Masonry/MASViewConstraint.m
  2. 8 0
      Tests/Specs/MASViewConstraintSpec.m

+ 2 - 0
Masonry/MASViewConstraint.m

@@ -235,6 +235,7 @@ static char kInstalledConstraintsKey;
     NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
     switch (layoutAttribute) {
         case NSLayoutAttributeLeft:
+        case NSLayoutAttributeLeading:
             self.layoutConstant = insets.left;
             break;
         case NSLayoutAttributeTop:
@@ -244,6 +245,7 @@ static char kInstalledConstraintsKey;
             self.layoutConstant = -insets.bottom;
             break;
         case NSLayoutAttributeRight:
+        case NSLayoutAttributeTrailing:
             self.layoutConstant = -insets.right;
             break;
         default:

+ 8 - 0
Tests/Specs/MASViewConstraintSpec.m

@@ -168,6 +168,10 @@ SpecBegin(MASViewConstraint) {
     left.equalTo(value);
     expect(left.layoutConstant).to.equal(20);
 
+    MASViewConstraint *leading = [[MASViewConstraint alloc] initWithFirstViewAttribute:otherView.mas_leading];
+    leading.equalTo(value);
+    expect(leading.layoutConstant).to.equal(20);
+
     MASViewConstraint *bottom = [[MASViewConstraint alloc] initWithFirstViewAttribute:otherView.mas_bottom];
     bottom.equalTo(value);
     expect(bottom.layoutConstant).to.equal(-30);
@@ -175,6 +179,10 @@ SpecBegin(MASViewConstraint) {
     MASViewConstraint *right = [[MASViewConstraint alloc] initWithFirstViewAttribute:otherView.mas_right];
     right.equalTo(value);
     expect(right.layoutConstant).to.equal(-40);
+
+    MASViewConstraint *trailing = [[MASViewConstraint alloc] initWithFirstViewAttribute:otherView.mas_trailing];
+    trailing.equalTo(value);
+    expect(trailing.layoutConstant).to.equal(-40);
     
     MASViewConstraint *centerX = [[MASViewConstraint alloc] initWithFirstViewAttribute:otherView.mas_centerX];
     centerX.equalTo(value);