MASConstraint+Private.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // MASConstraint+Private.h
  3. // Masonry
  4. //
  5. // Created by Nick Tymchenko on 29/04/14.
  6. // Copyright (c) 2014 cloudling. All rights reserved.
  7. //
  8. #import "MASConstraint.h"
  9. @protocol MASConstraintDelegate;
  10. @interface MASConstraint ()
  11. /**
  12. * Whether or not to check for an existing constraint instead of adding constraint
  13. */
  14. @property (nonatomic, assign) BOOL updateExisting;
  15. /**
  16. * Usually MASConstraintMaker but could be a parent MASConstraint
  17. */
  18. @property (nonatomic, weak) id<MASConstraintDelegate> delegate;
  19. /**
  20. * Based on a provided value type, is equal to calling:
  21. * NSNumber - setOffset:
  22. * NSValue with CGPoint - setPointOffset:
  23. * NSValue with CGSize - setSizeOffset:
  24. * NSValue with MASEdgeInsets - setInsets:
  25. */
  26. - (void)setLayoutConstantWithValue:(NSValue *)value;
  27. @end
  28. @interface MASConstraint (Abstract)
  29. /**
  30. * Sets the constraint relation to given NSLayoutRelation
  31. * returns a block which accepts one of the following:
  32. * MASViewAttribute, UIView, NSValue, NSArray
  33. * see readme for more details.
  34. */
  35. - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation;
  36. /**
  37. * Override to set a custom chaining behaviour
  38. */
  39. - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
  40. @end
  41. @protocol MASConstraintDelegate <NSObject>
  42. /**
  43. * Notifies the delegate when the constraint needs to be replaced with another constraint. For example
  44. * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks
  45. */
  46. - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint;
  47. - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
  48. @end