Bläddra i källkod

fix some typo and language stuff

bibibi 10 år sedan
förälder
incheckning
b461e4381f

+ 2 - 2
Examples/Masonry iOS Examples/MASExampleDistributeView.m

@@ -27,7 +27,7 @@
     unsigned int type  = arc4random()%4;
     switch (type) {
         case 0:
-            [arr mas_distributeViewsAlongAxis:MASAxisTypeHorizon withFixedSpacing:20 leadSpacing:5 tailSpacing:5];
+            [arr mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:20 leadSpacing:5 tailSpacing:5];
             [arr makeConstraints:^(MASConstraintMaker *make) {
                 make.top.equalTo(@60);
                 make.height.equalTo(@60);
@@ -41,7 +41,7 @@
             }];
             break;
         case 2:
-            [arr mas_distributeViewsAlongAxis:MASAxisTypeHorizon withFixedItemLength:30 leadSpacing:200 tailSpacing:30];
+            [arr mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedItemLength:30 leadSpacing:200 tailSpacing:30];
             [arr makeConstraints:^(MASConstraintMaker *make) {
                 make.top.equalTo(@60);
                 make.height.equalTo(@60);

+ 12 - 12
Masonry/NSArray+MASAdditions.h

@@ -11,7 +11,7 @@
 #import "MASViewAttribute.h"
 
 typedef NS_ENUM(NSUInteger, MASAxisType) {
-    MASAxisTypeHorizon,
+    MASAxisTypeHorizontal,
     MASAxisTypeVertical
 };
 
@@ -50,23 +50,23 @@ typedef NS_ENUM(NSUInteger, MASAxisType) {
 - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block;
 
 /**
- *  distribute with fixed spaceing
+ *  distribute with fixed spacing
  *
- *  @param axisType     horizon/vertical
- *  @param paddingSpace space
- *  @param leadSpacing  head
- *  @param tailSpacing  tail
+ *  @param axisType     which axis to distribute items along
+ *  @param fixedSpacing the spacing between each item
+ *  @param leadSpacing  the spacing before the first item and the container
+ *  @param tailSpacing  the spacing after the last item and the container
  */
-- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)paddingSpace leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
+- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
 
 /**
  *  distribute with fixed item size
  *
- *  @param axisType    horizon/vertical
- *  @param itemLength  item size
- *  @param leadSpacing head
- *  @param tailSpacing  tail
+ *  @param axisType        which axis to distribute items along
+ *  @param fixedItemLength the fixed length of each item
+ *  @param leadSpacing     the spacing before the first item and the container
+ *  @param tailSpacing     the spacing after the last item and the container
  */
-- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)itemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
+- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
 
 @end

+ 12 - 12
Masonry/NSArray+MASAdditions.m

@@ -38,21 +38,21 @@
     return constraints;
 }
 
-- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)paddingSpace leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing {
+- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing {
     if (self.count < 2) {
         NSAssert(self.count>1,@"views to distribute need to bigger than one");
         return;
     }
     
     MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews];
-    if (axisType == MASAxisTypeHorizon) {
+    if (axisType == MASAxisTypeHorizontal) {
         MAS_VIEW *prev;
         for (int i = 0; i < self.count; i++) {
             MAS_VIEW *v = [self objectAtIndex:i];
             [v mas_makeConstraints:^(MASConstraintMaker *make) {
                 if (prev) {
                     make.width.equalTo(prev);
-                    make.left.equalTo(prev.mas_right).offset(paddingSpace);
+                    make.left.equalTo(prev.mas_right).offset(fixedSpacing);
                     if (i == (CGFloat)self.count - 1) {//last one
                         make.right.equalTo(tempSuperView).offset(-tailSpacing);
                     }
@@ -72,7 +72,7 @@
             [v mas_makeConstraints:^(MASConstraintMaker *make) {
                 if (prev) {
                     make.height.equalTo(prev);
-                    make.top.equalTo(prev.mas_bottom).offset(paddingSpace);
+                    make.top.equalTo(prev.mas_bottom).offset(fixedSpacing);
                     if (i == (CGFloat)self.count - 1) {//last one
                         make.bottom.equalTo(tempSuperView).offset(-tailSpacing);
                     }                    
@@ -87,21 +87,21 @@
     }
 }
 
-- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)itemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing {
+- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing {
     if (self.count < 2) {
         NSAssert(self.count>1,@"views to distribute need to bigger than one");
         return;
     }
     
     MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews];
-    if (axisType == MASAxisTypeHorizon) {
+    if (axisType == MASAxisTypeHorizontal) {
         MAS_VIEW *prev;
         for (int i = 0; i < self.count; i++) {
             MAS_VIEW *v = [self objectAtIndex:i];
             [v mas_makeConstraints:^(MASConstraintMaker *make) {
                 if (prev) {
-                    CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(itemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
-                    make.width.equalTo(@(itemLength));
+                    CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
+                    make.width.equalTo(@(fixedItemLength));
                     if (i == (CGFloat)self.count - 1) {//last one
                         make.right.equalTo(tempSuperView).offset(-tailSpacing);
                     }
@@ -111,7 +111,7 @@
                 }
                 else {//first one
                     make.left.equalTo(tempSuperView).offset(leadSpacing);
-                    make.width.equalTo(@(itemLength));
+                    make.width.equalTo(@(fixedItemLength));
                 }
             }];
             prev = v;
@@ -123,8 +123,8 @@
             MAS_VIEW *v = [self objectAtIndex:i];
             [v mas_makeConstraints:^(MASConstraintMaker *make) {
                 if (prev) {
-                    CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(itemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
-                    make.height.equalTo(@(itemLength));
+                    CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
+                    make.height.equalTo(@(fixedItemLength));
                     if (i == (CGFloat)self.count - 1) {//last one
                         make.bottom.equalTo(tempSuperView).offset(-tailSpacing);
                     }
@@ -134,7 +134,7 @@
                 }
                 else {//first one
                     make.top.equalTo(tempSuperView).offset(leadSpacing);
-                    make.height.equalTo(@(itemLength));
+                    make.height.equalTo(@(fixedItemLength));
                 }
             }];
             prev = v;

+ 4 - 4
Tests/Specs/NSArray+MASAdditionsSpec.m

@@ -69,7 +69,7 @@ SpecBegin(NSArray_MASAdditions)
     [superView addSubview:subject2];
     NSArray *views = @[ subject1];
     expect(^{
-        [views mas_distributeViewsAlongAxis:MASAxisTypeHorizon withFixedSpacing:10.0 leadSpacing:5.0 tailSpacing:5.0];
+        [views mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:10.0 leadSpacing:5.0 tailSpacing:5.0];
     }).to.raiseAny();
     
 }
@@ -84,7 +84,7 @@ SpecBegin(NSArray_MASAdditions)
     [superView addSubview:subject2];
     NSArray *views = @[ subject1];
     expect(^{
-        [views mas_distributeViewsAlongAxis:MASAxisTypeHorizon withFixedSpacing:10.0 leadSpacing:5.0 tailSpacing:5.0];
+        [views mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:10.0 leadSpacing:5.0 tailSpacing:5.0];
     }).to.raiseAny();
     
 }
@@ -103,7 +103,7 @@ SpecBegin(NSArray_MASAdditions)
     
     NSArray *views = @[ subject1,subject2,subject3 ];
 
-    [views mas_distributeViewsAlongAxis:MASAxisTypeHorizon withFixedSpacing:10.0 leadSpacing:5.0 tailSpacing:5.0];
+    [views mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:10.0 leadSpacing:5.0 tailSpacing:5.0];
     
     //left view
     NSArray *arr1 = [MASViewConstraint installedConstraintsForView:subject1];
@@ -132,7 +132,7 @@ SpecBegin(NSArray_MASAdditions)
     
     NSArray *views = @[ subject1,subject2,subject3 ];
    
-    [views mas_distributeViewsAlongAxis:MASAxisTypeHorizon withFixedItemLength:30.0 leadSpacing:5.0 tailSpacing:5.0];
+    [views mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedItemLength:30.0 leadSpacing:5.0 tailSpacing:5.0];
     
     //left view
     NSArray *arr1 = [MASViewConstraint installedConstraintsForView:subject1];