猎豆优选

UIView+LayoutMethods.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // UIView+LayoutMethods.h
  3. // TmallClient4iOS-Prime
  4. //
  5. // Created by casa on 14/12/8.
  6. // Copyright (c) 2014年 casa. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
  10. //#define SCREEN_WIDTH ([[UIScreen mainScreen]bounds].size.width)
  11. //#define SCREEN_HEIGHT ([[UIScreen mainScreen]bounds].size.height)
  12. #define SCREEN_WITHOUT_STATUS_HEIGHT (SCREEN_HEIGHT - [[UIApplication sharedApplication] statusBarFrame].size.height)
  13. @interface UIView (LayoutMethods)
  14. @property(nonatomic, assign) IBInspectable CGFloat cornerRadius;
  15. // coordinator getters
  16. - (CGFloat)height;
  17. - (CGFloat)width;
  18. - (CGFloat)x;
  19. - (CGFloat)y;
  20. - (CGSize)size;
  21. - (CGPoint)origin;
  22. - (CGFloat)centerX;
  23. - (CGFloat)centerY;
  24. - (CGFloat)bottom;
  25. - (CGFloat)right;
  26. - (void)setX:(CGFloat)x;
  27. - (void)setY:(CGFloat)y;
  28. // height
  29. - (void)setHeight:(CGFloat)height;
  30. - (void)heightEqualToView:(UIView *)view;
  31. // width
  32. - (void)setWidth:(CGFloat)width;
  33. - (void)widthEqualToView:(UIView *)view;
  34. // center
  35. - (void)setCenterX:(CGFloat)centerX;
  36. - (void)setCenterY:(CGFloat)centerY;
  37. - (void)centerXEqualToView:(UIView *)view;
  38. - (void)centerYEqualToView:(UIView *)view;
  39. // top, bottom, left, right
  40. - (void)top:(CGFloat)top FromView:(UIView *)view;
  41. - (void)bottom:(CGFloat)bottom FromView:(UIView *)view;
  42. - (void)left:(CGFloat)left FromView:(UIView *)view;
  43. - (void)right:(CGFloat)right FromView:(UIView *)view;
  44. - (void)topInContainer:(CGFloat)top shouldResize:(BOOL)shouldResize;
  45. - (void)bottomInContainer:(CGFloat)bottom shouldResize:(BOOL)shouldResize;
  46. - (void)leftInContainer:(CGFloat)left shouldResize:(BOOL)shouldResize;
  47. - (void)rightInContainer:(CGFloat)right shouldResize:(BOOL)shouldResize;
  48. - (void)topEqualToView:(UIView *)view;
  49. - (void)bottomEqualToView:(UIView *)view;
  50. - (void)leftEqualToView:(UIView *)view;
  51. - (void)rightEqualToView:(UIView *)view;
  52. // size
  53. - (void)setSize:(CGSize)size;
  54. - (void)sizeEqualToView:(UIView *)view;
  55. // imbueset
  56. - (void)fillWidth;
  57. - (void)fillHeight;
  58. - (void)fill;
  59. - (UIView *)topSuperView;
  60. /**
  61. * Removes all subviews.
  62. */
  63. - (void)removeAllSubviews;
  64. @end
  65. @protocol LayoutProtocol
  66. @required
  67. // put your layout code here
  68. - (void)calculateLayout;
  69. @end