UIView+MAC.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. //
  2. // UIView+MAC.h
  3. // WeiSchoolTeacher
  4. //
  5. // Created by MacKun on 15/12/11.
  6. // Copyright © 2015年 MacKun. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. typedef NS_ENUM(NSInteger ,UIViewRadiusType) {
  10. UIViewRadiusTypeNone = 0, // 无特别限制,四个角全切
  11. UIViewRadiusTypeTopLeft, // 左上
  12. UIViewRadiusTypeTopRight, // 右上
  13. UIViewRadiusTypeBottomLeft, // 左下
  14. UIViewRadiusTypeBottomRight // 右下
  15. };
  16. @interface UIView(MAC)
  17. @property (nonatomic, assign) CGSize size;
  18. @property (nonatomic, assign) CGFloat left;
  19. @property (nonatomic, assign) CGFloat right;
  20. @property (nonatomic, assign) CGFloat top;
  21. @property (nonatomic, assign) CGFloat bottom;
  22. @property (nonatomic, assign) CGFloat centerX;
  23. @property (nonatomic, assign) CGFloat centerY;
  24. @property (nonatomic, assign) CGFloat width;
  25. @property (nonatomic, assign) CGFloat height;
  26. @property(retain) id cookie;
  27. /**
  28. * @brief 找到当前view所在的viewcontroler
  29. */
  30. @property (readonly) UIViewController *viewController;
  31. /**
  32. * 底部加阴影
  33. */
  34. -(void)addShadowonBottom;
  35. /**
  36. * 加灰色阴影
  37. */
  38. -(void)addGrayGradientShadow;
  39. /**
  40. * 顶部加阴影
  41. */
  42. -(void)addShadowonTop;
  43. /**
  44. * 移动加阴影
  45. */
  46. -(void)addMovingShadow;
  47. /**
  48. 添加阴影
  49. */
  50. -(void)addShadowWithColor:(UIColor *)color width:(CGFloat)width opacity:(CGFloat)opacity;
  51. /**
  52. * 移除阴影
  53. */
  54. -(void)removeShadow;
  55. /**
  56. * 相对Rect居中
  57. */
  58. - (void)centerInRect:(CGRect)rect;
  59. /**
  60. * 相对Rect垂直居中
  61. */
  62. - (void)centerVerticallyInRect:(CGRect)rect;
  63. /**
  64. * 相对Rect水平居中
  65. */
  66. - (void)centerHorizontallyInRect:(CGRect)rect;
  67. /**
  68. * 相对父视图居中
  69. */
  70. - (void)centerInSuperView;
  71. /**
  72. * 相对父视图垂直居中
  73. */
  74. - (void)centerVerticallyInSuperView;
  75. /**
  76. * 相对父视图水平居中
  77. */
  78. - (void)centerHorizontallyInSuperView;
  79. /**
  80. * 同一父视图的兄弟视图水平居中
  81. */
  82. - (void)centerHorizontallyBelow:(UIView *)view padding:(CGFloat)padding;
  83. /**
  84. * 同一父视图的兄弟视图水平居中
  85. */
  86. - (void)centerHorizontallyBelow:(UIView *)view;
  87. /*
  88. * 设置窗体大小
  89. */
  90. - (void)setFrameSize:(CGSize)newSize;
  91. /*
  92. * 设置窗体宽度
  93. */
  94. - (void)setFrameWidth:(CGFloat)newWidth;
  95. /*
  96. * 设置窗体高度
  97. */
  98. - (void)setFrameHeight:(CGFloat)newHeight;
  99. /*
  100. * 设置窗体起始位置
  101. */
  102. - (void)setFrameOrigin:(CGPoint)newOrigin;
  103. /*
  104. * 设置窗体起始X
  105. */
  106. - (void)setFrameOriginX:(CGFloat)newX;
  107. /*
  108. * 设置窗体起始Y
  109. */
  110. - (void)setFrameOriginY:(CGFloat)newY;
  111. /*
  112. * 增加窗体宽度
  113. */
  114. - (void)addSizeWidth:(CGFloat)newWidth;
  115. /*
  116. * 增加窗体高度
  117. */
  118. - (void)addSizeHeight:(CGFloat)newHeight;
  119. /*
  120. * 移动窗体起始X位置
  121. */
  122. - (void)addOriginX:(CGFloat)newX;
  123. /*
  124. * 移动窗体起始Y位置
  125. */
  126. - (void)addOriginY:(CGFloat)newY;
  127. - (void)cornerRadius:(CGFloat)cornerRadius withUIViewRadiusType:(UIViewRadiusType)type;
  128. @end