NSLayoutConstraint+Additions.m 910 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // NSLayoutConstraint+Additions.m
  3. // OneCable
  4. //
  5. // Created by Jason Lee on 1/5/16.
  6. // Copyright © 2016 ntels. All rights reserved.
  7. //
  8. #import "NSLayoutConstraint+Additions.h"
  9. @implementation NSLayoutConstraint (Additions)
  10. - (NSLayoutConstraint *)setMutltiplier:(CGFloat)multiplier {
  11. NSLayoutConstraint *newConstraint = [NSLayoutConstraint constraintWithItem:self.firstItem attribute:self.firstAttribute relatedBy:self.relation toItem:self.secondItem attribute:self.secondAttribute multiplier:multiplier constant:self.constant];
  12. newConstraint.priority = self.priority;
  13. newConstraint.shouldBeArchived = self.shouldBeArchived;
  14. newConstraint.identifier = self.identifier;
  15. newConstraint.active = self.active;
  16. [NSLayoutConstraint deactivateConstraints:@[self]];
  17. [NSLayoutConstraint activateConstraints:@[newConstraint]];
  18. return newConstraint;
  19. }
  20. @end