UIView+Extension.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // UIView+Extension.h
  3. // JWlive
  4. //
  5. // Created by pican zhang on 16/3/17.
  6. // Copyright © 2016年 pican zhang. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @interface UIView (Extension)
  10. //获取UIView的frame
  11. @property (nonatomic, assign) CGFloat x;
  12. @property (nonatomic, assign) CGFloat y;
  13. @property (nonatomic, assign) CGFloat centerX;
  14. @property (nonatomic, assign) CGFloat centerY;
  15. @property (nonatomic, assign) CGFloat width;
  16. @property (nonatomic, assign) CGFloat height;
  17. @property (nonatomic, assign) CGSize size;
  18. @property (assign, nonatomic) CGPoint origin;
  19. //给UIView画灰色的线
  20. - (void)HorizonLinePaddingToTop:(CGFloat)top;
  21. - (void)VerticalLinePaddingToLeft:(CGFloat)left;
  22. - (void)RightLinePaddingTop:(CGFloat)top;
  23. - (void)LeftLinePaddingTop:(CGFloat)top;
  24. //绘制顶部的线
  25. - (void)topLinepaddingLeft:(CGFloat)left;
  26. - (void)topLineforView;
  27. - (void)topLineforViewWithColor:(UIColor*)color;
  28. //绘制底部的线
  29. - (void)bottomLineforViewHeight:(CGFloat)height;
  30. - (void)bottomLineforView;
  31. - (void)bottomLineforViewWithColor:(UIColor*)color;
  32. - (void)bottomWideLineforView:(CGFloat)height;
  33. - (void)addLineWithColor:(UIColor *)color lineRect:(CGRect)rect;
  34. //找到自己的vc
  35. - (UIViewController *)viewController;
  36. /**
  37. 将像素point由point所在视图转换到目标view或window中,返回在目标view或window中的像素值
  38. @param point 在视图的局部坐标(bounds)中指定的像素点。
  39. @param view 要转换为其坐标点的view或window。如果view为nil,此方法将转换为window基坐标。
  40. @return 像素点转换为view或window的坐标。
  41. */
  42. - (CGPoint)convertPoint:(CGPoint)point toViewOrWindow:(nullable UIView *)view;
  43. /**
  44. 将像素point从view或window中转换到当前视图中,返回在当前视图中的像素值
  45. @param point 在视图的局部坐标(bounds)中指定的像素点。
  46. @param view 要转换为其坐标点的view或window。如果view为nil,此方法将转换为window基坐标。
  47. @return 像素点转换为view或window的坐标。
  48. */
  49. - (CGPoint)convertPoint:(CGPoint)point fromViewOrWindow:(nullable UIView *)view;
  50. /**
  51. 将rect由rect所在视图转换到目标视图view中,返回在目标视图view或window中的rect
  52. @param rect 需要转换视图的rect
  53. @param view 要转换为其坐标点的view或window。如果view为nil,此方法将转换为window基坐标。
  54. @return 转换后的rect
  55. */
  56. - (CGRect)convertRect:(CGRect)rect toViewOrWindow:(nullable UIView *)view;
  57. /**
  58. 将rect从view或window中转换到当前视图中,返回在当前视图中的rect
  59. @param rect 需要转换视图的rect
  60. @param view 要转换为其坐标点的view或window。如果view为nil,此方法将转换为window基坐标。
  61. @return 转换后的rect
  62. */
  63. - (CGRect)convertRect:(CGRect)rect fromViewOrWindow:(nullable UIView *)view;
  64. @end