UIView+ITTAdditions.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. //
  2. // UIView+ITTAdditions.h
  3. // Sword
  4. //
  5. // Created by jack 廉洁 on 3/15/12.
  6. // Copyright (c) 2012 iTotemStudio. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @interface UIView (ITTAdditions)
  10. /**
  11. * Shortcut for frame.origin.x.
  12. *
  13. * Sets frame.origin.x = left
  14. */
  15. @property (nonatomic) CGFloat left;
  16. /**
  17. * Shortcut for frame.origin.y
  18. *
  19. * Sets frame.origin.y = top
  20. */
  21. @property (nonatomic) CGFloat top;
  22. /**
  23. * Shortcut for frame.origin.x + frame.size.width
  24. *
  25. * Sets frame.origin.x = right - frame.size.width
  26. */
  27. @property (nonatomic) CGFloat right;
  28. /**
  29. * Shortcut for frame.origin.y + frame.size.height
  30. *
  31. * Sets frame.origin.y = bottom - frame.size.height
  32. */
  33. @property (nonatomic) CGFloat bottom;
  34. /**
  35. * Shortcut for frame.size.width
  36. *
  37. * Sets frame.size.width = width
  38. */
  39. @property (nonatomic) CGFloat width;
  40. /**
  41. * Shortcut for frame.size.height
  42. *
  43. * Sets frame.size.height = height
  44. */
  45. @property (nonatomic) CGFloat height;
  46. /**
  47. * Shortcut for center.x
  48. *
  49. * Sets center.x = centerX
  50. */
  51. @property (nonatomic) CGFloat centerX;
  52. /**
  53. * Shortcut for center.y
  54. *
  55. * Sets center.y = centerY
  56. */
  57. @property (nonatomic) CGFloat centerY;
  58. /**
  59. * Return the x coordinate on the screen.
  60. */
  61. @property (nonatomic, readonly) CGFloat ttScreenX;
  62. /**
  63. * Return the y coordinate on the screen.
  64. */
  65. @property (nonatomic, readonly) CGFloat ttScreenY;
  66. /**
  67. * Return the x coordinate on the screen, taking into account scroll views.
  68. */
  69. @property (nonatomic, readonly) CGFloat screenViewX;
  70. /**
  71. * Return the y coordinate on the screen, taking into account scroll views.
  72. */
  73. @property (nonatomic, readonly) CGFloat screenViewY;
  74. /**
  75. * Return the view frame on the screen, taking into account scroll views.
  76. */
  77. @property (nonatomic, readonly) CGRect screenFrame;
  78. /**
  79. * Shortcut for frame.origin
  80. */
  81. @property (nonatomic) CGPoint origin;
  82. /**
  83. * Shortcut for frame.size
  84. */
  85. @property (nonatomic) CGSize size;
  86. /**
  87. * Return the width in portrait or the height in landscape.
  88. */
  89. @property (nonatomic, readonly) CGFloat orientationWidth;
  90. /**
  91. * Return the height in portrait or the width in landscape.
  92. */
  93. @property (nonatomic, readonly) CGFloat orientationHeight;
  94. /**
  95. * Finds the first descendant view (including this view) that is a member of a particular class.
  96. */
  97. - (UIView*)descendantOrSelfWithClass:(Class)cls;
  98. /**
  99. * Finds the first ancestor view (including this view) that is a member of a particular class.
  100. */
  101. - (UIView*)ancestorOrSelfWithClass:(Class)cls;
  102. /**
  103. * Removes all subviews.
  104. */
  105. - (void)removeAllSubviews;
  106. /**
  107. * Calculates the offset of this view from another view in screen coordinates.
  108. *
  109. * otherView should be a parent view of this view.
  110. */
  111. - (CGPoint)offsetFromView:(UIView*)otherView;
  112. /**
  113. * Set view's layer bound color
  114. */
  115. - (void)setBorderColor:(UIColor *)borderColor width:(CGFloat)borderWidth;
  116. @end