|
12 | 12 | #import "MASConstraint+Private.h"
|
13 | 13 | #import "MASViewAttribute.h"
|
14 | 14 | #import "View+MASAdditions.h"
|
| 15 | +#import "LayoutGuide+MASAdditions.h" |
15 | 16 |
|
16 | 17 | @interface MASConstraintMaker () <MASConstraintDelegate>
|
17 | 18 |
|
18 | 19 | @property (nonatomic, weak) MAS_VIEW *view;
|
19 |
| -@property (nonatomic, weak) id item; |
| 20 | +@property (nonatomic, weak) MASLayoutGuide *item; |
20 | 21 | @property (nonatomic, strong) NSMutableArray *constraints;
|
21 | 22 |
|
22 | 23 | @end
|
@@ -95,17 +96,19 @@ - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs {
|
95 | 96 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)");
|
96 | 97 |
|
97 | 98 | NSMutableArray *attributes = [NSMutableArray array];
|
| 99 | + |
| 100 | +#define layoutItem ((MAS_VIEW *)(self.item ?: self.view)) |
98 | 101 |
|
99 |
| - if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left]; |
100 |
| - if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right]; |
101 |
| - if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top]; |
102 |
| - if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom]; |
103 |
| - if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading]; |
104 |
| - if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing]; |
105 |
| - if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width]; |
106 |
| - if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height]; |
107 |
| - if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX]; |
108 |
| - if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY]; |
| 102 | + if (attrs & MASAttributeLeft) [attributes addObject:layoutItem.mas_left]; |
| 103 | + if (attrs & MASAttributeRight) [attributes addObject:layoutItem.mas_right]; |
| 104 | + if (attrs & MASAttributeTop) [attributes addObject:layoutItem.mas_top]; |
| 105 | + if (attrs & MASAttributeBottom) [attributes addObject:layoutItem.mas_bottom]; |
| 106 | + if (attrs & MASAttributeLeading) [attributes addObject:layoutItem.mas_leading]; |
| 107 | + if (attrs & MASAttributeTrailing) [attributes addObject:layoutItem.mas_trailing]; |
| 108 | + if (attrs & MASAttributeWidth) [attributes addObject:layoutItem.mas_width]; |
| 109 | + if (attrs & MASAttributeHeight) [attributes addObject:layoutItem.mas_height]; |
| 110 | + if (attrs & MASAttributeCenterX) [attributes addObject:layoutItem.mas_centerX]; |
| 111 | + if (attrs & MASAttributeCenterY) [attributes addObject:layoutItem.mas_centerY]; |
109 | 112 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline];
|
110 | 113 | if (attrs & MASAttributeFirstBaseline) [attributes addObject:self.view.mas_firstBaseline];
|
111 | 114 | if (attrs & MASAttributeLastBaseline) [attributes addObject:self.view.mas_lastBaseline];
|
|
0 commit comments