Skip to content

Commit 7cd0e1c

Browse files
committed
fix issue: can’t set width and height for MASLayoutGuide
1 parent cc7d2eb commit 7cd0e1c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Masonry/MASViewConstraint.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,11 @@ - (BOOL)hasBeenInstalled {
137137
- (void)setSecondViewAttribute:(id)secondViewAttribute {
138138
if ([secondViewAttribute isKindOfClass:NSValue.class]) {
139139
if ([self.firstViewAttribute.item isKindOfClass:MASLayoutGuide.class]) {
140-
_secondViewAttribute = [[MASViewAttribute alloc] initWithView:self.firstViewAttribute.view
141-
layoutAttribute:self.firstViewAttribute.layoutAttribute];
140+
NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
141+
if (layoutAttribute != NSLayoutAttributeWidth && layoutAttribute != NSLayoutAttributeHeight) {
142+
_secondViewAttribute = [[MASViewAttribute alloc] initWithView:self.firstViewAttribute.view
143+
layoutAttribute:layoutAttribute];
144+
}
142145
}
143146

144147
[self setLayoutConstantWithValue:secondViewAttribute];

0 commit comments

Comments
 (0)