UIView+AddConstraints.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // UIView+AddConstraints.h
  3. // SnailPopupControllerDemo
  4. //
  5. // Created by voquan on 2017/3/31.
  6. // Copyright © 2017年 voquan. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @class SnailConstraintMaker, SnailConstraint;
  10. @interface UIView (AddConstraints)
  11. - (NSArray *)zh_makeConstraints:(void(^)(SnailConstraintMaker *make))block;
  12. @end
  13. @interface SnailConstraintMaker : NSObject
  14. @property (nonatomic, strong, readonly) SnailConstraint *left;
  15. @property (nonatomic, strong, readonly) SnailConstraint *top;
  16. @property (nonatomic, strong, readonly) SnailConstraint *right;
  17. @property (nonatomic, strong, readonly) SnailConstraint *bottom;
  18. @property (nonatomic, strong, readonly) SnailConstraint *edges;
  19. @property (nonatomic, strong, readonly) SnailConstraint *width;
  20. @property (nonatomic, strong, readonly) SnailConstraint *height;
  21. @property (nonatomic, strong, readonly) SnailConstraint *size;
  22. @property (nonatomic, strong, readonly) SnailConstraint *centerX;
  23. @property (nonatomic, strong, readonly) SnailConstraint *centerY;
  24. @property (nonatomic, strong, readonly) SnailConstraint *center;
  25. - (id)initWithView:(UIView *)view;
  26. - (NSArray *)install; // @return an array of all the installed SnailConstraints
  27. @end
  28. @interface SnailConstraint : NSObject
  29. @property (nonatomic, strong) NSMutableArray *layoutAttributes;
  30. @property (nonatomic, weak) UIView *firstItem;
  31. - (instancetype)initWithView:(UIView *)view;
  32. - (void)install;
  33. - (SnailConstraint *)equalTo:(UIView *)view;
  34. - (SnailConstraint *)zh_equalTo:(CGFloat)c;
  35. @end