NSArray+MASAdditions.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // NSArray+MASAdditions.h
  3. //
  4. //
  5. // Created by Daniel Hammond on 11/26/13.
  6. //
  7. //
  8. #import "MASUtilities.h"
  9. #import "MASConstraintMaker.h"
  10. #import "MASViewAttribute.h"
  11. typedef NS_ENUM(NSUInteger, MASAxisType) {
  12. MASAxisTypeHorizontal,
  13. MASAxisTypeVertical
  14. };
  15. @interface NSArray (MASAdditions)
  16. /**
  17. * Creates a MASConstraintMaker with each view in the callee.
  18. * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view
  19. *
  20. * @param block scope within which you can build up the constraints which you wish to apply to each view.
  21. *
  22. * @return Array of created MASConstraints
  23. */
  24. - (NSArray *)mas_makeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block;
  25. /**
  26. * Creates a MASConstraintMaker with each view in the callee.
  27. * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
  28. * If an existing constraint exists then it will be updated instead.
  29. *
  30. * @param block scope within which you can build up the constraints which you wish to apply to each view.
  31. *
  32. * @return Array of created/updated MASConstraints
  33. */
  34. - (NSArray *)mas_updateConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block;
  35. /**
  36. * Creates a MASConstraintMaker with each view in the callee.
  37. * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
  38. * All constraints previously installed for the views will be removed.
  39. *
  40. * @param block scope within which you can build up the constraints which you wish to apply to each view.
  41. *
  42. * @return Array of created/updated MASConstraints
  43. */
  44. - (NSArray *)mas_remakeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block;
  45. /**
  46. * distribute with fixed spacing
  47. *
  48. * @param axisType which axis to distribute items along
  49. * @param fixedSpacing the spacing between each item
  50. * @param leadSpacing the spacing before the first item and the container
  51. * @param tailSpacing the spacing after the last item and the container
  52. */
  53. - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
  54. /**
  55. * distribute with fixed item size
  56. *
  57. * @param axisType which axis to distribute items along
  58. * @param fixedItemLength the fixed length of each item
  59. * @param leadSpacing the spacing before the first item and the container
  60. * @param tailSpacing the spacing after the last item and the container
  61. */
  62. - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
  63. @end