悟空记账

IQUIView+Hierarchy.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // IQUIView+Hierarchy.h
  3. // https://github.com/hackiftekhar/IQKeyboardManager
  4. // Copyright (c) 2013-16 Iftekhar Qurashi.
  5. //
  6. // Permission is hereby granted, free of charge, to any person obtaining a copy
  7. // of this software and associated documentation files (the "Software"), to deal
  8. // in the Software without restriction, including without limitation the rights
  9. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. // copies of the Software, and to permit persons to whom the Software is
  11. // furnished to do so, subject to the following conditions:
  12. //
  13. // The above copyright notice and this permission notice shall be included in
  14. // all copies or substantial portions of the Software.
  15. //
  16. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. // THE SOFTWARE.
  23. #import <UIKit/UIView.h>
  24. #import "IQKeyboardManagerConstants.h"
  25. @class UICollectionView, UIScrollView, UITableView, NSArray;
  26. /**
  27. UIView hierarchy category.
  28. */
  29. @interface UIView (IQ_UIView_Hierarchy)
  30. ///----------------------
  31. /// @name viewControllers
  32. ///----------------------
  33. /**
  34. Returns the UIViewController object that manages the receiver.
  35. */
  36. @property (nullable, nonatomic, readonly, strong) UIViewController *viewController;
  37. /**
  38. Returns the topMost UIViewController object in hierarchy.
  39. */
  40. @property (nullable, nonatomic, readonly, strong) UIViewController *topMostController;
  41. ///-----------------------------------
  42. /// @name Superviews/Subviews/Siglings
  43. ///-----------------------------------
  44. /**
  45. Returns the superView of provided class type.
  46. */
  47. -(nullable UIView*)superviewOfClassType:(nonnull Class)classType;
  48. /**
  49. Returns all siblings of the receiver which canBecomeFirstResponder.
  50. */
  51. @property (nonnull, nonatomic, readonly, copy) NSArray *responderSiblings;
  52. /**
  53. Returns all deep subViews of the receiver which canBecomeFirstResponder.
  54. */
  55. @property (nonnull, nonatomic, readonly, copy) NSArray *deepResponderViews;
  56. ///-------------------------
  57. /// @name Special TextFields
  58. ///-------------------------
  59. /**
  60. Returns YES if the receiver object is UISearchBarTextField, otherwise return NO.
  61. */
  62. @property (nonatomic, getter=isSearchBarTextField, readonly) BOOL searchBarTextField;
  63. /**
  64. Returns YES if the receiver object is UIAlertSheetTextField, otherwise return NO.
  65. */
  66. @property (nonatomic, getter=isAlertViewTextField, readonly) BOOL alertViewTextField;
  67. ///----------------
  68. /// @name Transform
  69. ///----------------
  70. /**
  71. Returns current view transform with respect to the 'toView'.
  72. */
  73. -(CGAffineTransform)convertTransformToView:(nullable UIView*)toView;
  74. ///-----------------
  75. /// @name Hierarchy
  76. ///-----------------
  77. /**
  78. Returns a string that represent the information about it's subview's hierarchy. You can use this method to debug the subview's positions.
  79. */
  80. @property (nonnull, nonatomic, readonly, copy) NSString *subHierarchy;
  81. /**
  82. Returns an string that represent the information about it's upper hierarchy. You can use this method to debug the superview's positions.
  83. */
  84. @property (nonnull, nonatomic, readonly, copy) NSString *superHierarchy;
  85. /**
  86. Returns an string that represent the information about it's frame positions. You can use this method to debug self positions.
  87. */
  88. @property (nonnull, nonatomic, readonly, copy) NSString *debugHierarchy;
  89. @end
  90. /**
  91. NSObject category to used for logging purposes
  92. */
  93. @interface NSObject (IQ_Logging)
  94. /**
  95. Short description for logging purpose.
  96. */
  97. @property (nonnull, nonatomic, readonly, copy) NSString *_IQDescription;
  98. @end