UIView+ViewController.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // UIView+ViewController.h
  3. // Created by MacKun on 15/4/25.
  4. // Copyright (c) 2015年 MacKun All rights reserved.
  5. //
  6. #import <UIKit/UIKit.h>
  7. @interface UIView (ViewController)
  8. /**
  9. * @brief 找到当前view所在的viewcontroler
  10. */
  11. @property (readonly) UIViewController *viewController;
  12. /**
  13. Remove all subviews.
  14. @warning Never call this method inside your view's drawRect: method.
  15. */
  16. - (void)removeAllSubviews;
  17. /**
  18. Converts a point from the receiver's coordinate system to that of the specified view or window.
  19. @param point A point specified in the local coordinate system (bounds) of the receiver.
  20. @param view The view or window into whose coordinate system point is to be converted.
  21. If view is nil, this method instead converts to window base coordinates.
  22. @return The point converted to the coordinate system of view.
  23. */
  24. - (CGPoint)convertPoint:(CGPoint)point toViewOrWindow:(UIView *)view;
  25. /**
  26. Converts a point from the coordinate system of a given view or window to that of the receiver.
  27. @param point A point specified in the local coordinate system (bounds) of view.
  28. @param view The view or window with point in its coordinate system.
  29. If view is nil, this method instead converts from window base coordinates.
  30. @return The point converted to the local coordinate system (bounds) of the receiver.
  31. */
  32. - (CGPoint)convertPoint:(CGPoint)point fromViewOrWindow:(UIView *)view;
  33. /**
  34. Converts a rectangle from the receiver's coordinate system to that of another view or window.
  35. @param rect A rectangle specified in the local coordinate system (bounds) of the receiver.
  36. @param view The view or window that is the target of the conversion operation. If view is nil, this method instead converts to window base coordinates.
  37. @return The converted rectangle.
  38. */
  39. - (CGRect)convertRect:(CGRect)rect toViewOrWindow:(UIView *)view;
  40. /**
  41. Converts a rectangle from the coordinate system of another view or window to that of the receiver.
  42. @param rect A rectangle specified in the local coordinate system (bounds) of view.
  43. @param view The view or window with rect in its coordinate system.
  44. If view is nil, this method instead converts from window base coordinates.
  45. @return The converted rectangle.
  46. */
  47. - (CGRect)convertRect:(CGRect)rect fromViewOrWindow:(UIView *)view;
  48. /// 移除所有子视图中 tableview、scrollview 的 delegate、datasource
  49. - (void)clearScrollViewDelegate;
  50. - (void)removeAllGestures;
  51. - (void)removeAllGesturesWithSubViews;
  52. /// 在 block 内禁用动画
  53. + (void)disableAnimationWithBlock:(void (^)(void))block;
  54. @end