old mode 100644
new mode 100755
| | |
| | | // |
| | | // MASConstraint.m |
| | | // MASViewConstraint.m |
| | | // Masonry |
| | | // |
| | | // Created by Jonas Budelmann on 20/07/13. |
| | |
| | | - (void)setLayoutConstant:(CGFloat)layoutConstant { |
| | | _layoutConstant = layoutConstant; |
| | | |
| | | #if TARGET_OS_MAC && !TARGET_OS_IPHONE |
| | | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) |
| | | if (self.useAnimator) { |
| | | [self.layoutConstraint.animator setConstant:layoutConstant]; |
| | | } else { |
| | |
| | | NSMutableArray *children = NSMutableArray.new; |
| | | for (id attr in attribute) { |
| | | MASViewConstraint *viewConstraint = [self copy]; |
| | | viewConstraint.layoutRelation = relation; |
| | | viewConstraint.secondViewAttribute = attr; |
| | | [children addObject:viewConstraint]; |
| | | } |
| | |
| | | |
| | | #pragma mark - Animator proxy |
| | | |
| | | #if TARGET_OS_MAC && !TARGET_OS_IPHONE |
| | | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) |
| | | |
| | | - (MASConstraint *)animator { |
| | | self.useAnimator = YES; |
| | |
| | | } |
| | | } |
| | | |
| | | - (void)setInset:(CGFloat)inset { |
| | | [self setInsets:(MASEdgeInsets){.top = inset, .left = inset, .bottom = inset, .right = inset}]; |
| | | } |
| | | |
| | | - (void)setOffset:(CGFloat)offset { |
| | | self.layoutConstant = offset; |
| | | } |
| | |
| | | #pragma mark - MASConstraint |
| | | |
| | | - (void)activate { |
| | | if ([self supportsActiveProperty] && self.layoutConstraint) { |
| | | if (self.hasBeenInstalled) { |
| | | return; |
| | | } |
| | | self.layoutConstraint.active = YES; |
| | | [self.firstViewAttribute.view.mas_installedConstraints addObject:self]; |
| | | } else { |
| | | [self install]; |
| | | } |
| | | [self install]; |
| | | } |
| | | |
| | | - (void)deactivate { |
| | | if ([self supportsActiveProperty]) { |
| | | self.layoutConstraint.active = NO; |
| | | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; |
| | | } else { |
| | | [self uninstall]; |
| | | } |
| | | [self uninstall]; |
| | | } |
| | | |
| | | - (void)install { |
| | | if (self.hasBeenInstalled) { |
| | | return; |
| | | } |
| | | |
| | | if ([self supportsActiveProperty] && self.layoutConstraint) { |
| | | self.layoutConstraint.active = YES; |
| | | [self.firstViewAttribute.view.mas_installedConstraints addObject:self]; |
| | | return; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | - (void)uninstall { |
| | | if ([self supportsActiveProperty]) { |
| | | self.layoutConstraint.active = NO; |
| | | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; |
| | | return; |
| | | } |
| | | |
| | | [self.installedView removeConstraint:self.layoutConstraint]; |
| | | self.layoutConstraint = nil; |
| | | self.installedView = nil; |