瀏覽代碼

fix a bug cause by set leading or tail space

bibibi 10 年之前
父節點
當前提交
15293124f8
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 2 2
      Examples/Masonry iOS Examples/MASExampleDistributeView.m
  2. 2 2
      Masonry/NSArray+MASAdditions.m

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

@@ -41,14 +41,14 @@
             }];
             break;
         case 2:
-            [arr mas_distributeViewsAlongAxis:MASAxisTypeHorizon withFixedItemLength:30 leadSpacing:5 tailSpacing:5];
+            [arr mas_distributeViewsAlongAxis:MASAxisTypeHorizon withFixedItemLength:30 leadSpacing:200 tailSpacing:30];
             [arr makeConstraints:^(MASConstraintMaker *make) {
                 make.top.equalTo(@60);
                 make.height.equalTo(@60);
             }];
             break;
         case 3:
-            [arr mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedItemLength:30 leadSpacing:5 tailSpacing:5];
+            [arr mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedItemLength:30 leadSpacing:30 tailSpacing:200];
             [arr makeConstraints:^(MASConstraintMaker *make) {
                 make.left.equalTo(@0);
                 make.width.equalTo(@60);

+ 2 - 2
Masonry/NSArray+MASAdditions.m

@@ -100,7 +100,7 @@
             MAS_VIEW *v = [self objectAtIndex:i];
             [v mas_makeConstraints:^(MASConstraintMaker *make) {
                 if (prev) {
-                    CGFloat offset = (1-(i/((CGFloat)self.count-1)))*itemLength;
+                    CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(itemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
                     make.width.equalTo(@(itemLength));
                     if (i == (CGFloat)self.count - 1) {//last one
                         make.right.equalTo(tempSuperView).offset(-tailSpacing);
@@ -123,7 +123,7 @@
             MAS_VIEW *v = [self objectAtIndex:i];
             [v mas_makeConstraints:^(MASConstraintMaker *make) {
                 if (prev) {
-                    CGFloat offset = (1-(i/((CGFloat)self.count-1)))*itemLength;
+                    CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(itemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
                     make.height.equalTo(@(itemLength));
                     if (i == (CGFloat)self.count - 1) {//last one
                         make.bottom.equalTo(tempSuperView).offset(-tailSpacing);