ConstraintMakerExtendable.swift 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. //
  2. // SnapKit
  3. //
  4. // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
  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. #if os(iOS) || os(tvOS)
  24. import UIKit
  25. #else
  26. import AppKit
  27. #endif
  28. public class ConstraintMakerExtendable: ConstraintMakerRelatable {
  29. public var left: ConstraintMakerExtendable {
  30. self.description.attributes += .left
  31. return self
  32. }
  33. public var top: ConstraintMakerExtendable {
  34. self.description.attributes += .top
  35. return self
  36. }
  37. public var bottom: ConstraintMakerExtendable {
  38. self.description.attributes += .bottom
  39. return self
  40. }
  41. public var right: ConstraintMakerExtendable {
  42. self.description.attributes += .right
  43. return self
  44. }
  45. public var leading: ConstraintMakerExtendable {
  46. self.description.attributes += .leading
  47. return self
  48. }
  49. public var trailing: ConstraintMakerExtendable {
  50. self.description.attributes += .trailing
  51. return self
  52. }
  53. public var width: ConstraintMakerExtendable {
  54. self.description.attributes += .width
  55. return self
  56. }
  57. public var height: ConstraintMakerExtendable {
  58. self.description.attributes += .height
  59. return self
  60. }
  61. public var centerX: ConstraintMakerExtendable {
  62. self.description.attributes += .centerX
  63. return self
  64. }
  65. public var centerY: ConstraintMakerExtendable {
  66. self.description.attributes += .centerY
  67. return self
  68. }
  69. @available(*, deprecated, renamed:"lastBaseline")
  70. public var baseline: ConstraintMakerExtendable {
  71. self.description.attributes += .lastBaseline
  72. return self
  73. }
  74. public var lastBaseline: ConstraintMakerExtendable {
  75. self.description.attributes += .lastBaseline
  76. return self
  77. }
  78. @available(iOS 8.0, OSX 10.11, *)
  79. public var firstBaseline: ConstraintMakerExtendable {
  80. self.description.attributes += .firstBaseline
  81. return self
  82. }
  83. @available(iOS 8.0, *)
  84. public var leftMargin: ConstraintMakerExtendable {
  85. self.description.attributes += .leftMargin
  86. return self
  87. }
  88. @available(iOS 8.0, *)
  89. public var rightMargin: ConstraintMakerExtendable {
  90. self.description.attributes += .rightMargin
  91. return self
  92. }
  93. @available(iOS 8.0, *)
  94. public var topMargin: ConstraintMakerExtendable {
  95. self.description.attributes += .topMargin
  96. return self
  97. }
  98. @available(iOS 8.0, *)
  99. public var bottomMargin: ConstraintMakerExtendable {
  100. self.description.attributes += .bottomMargin
  101. return self
  102. }
  103. @available(iOS 8.0, *)
  104. public var leadingMargin: ConstraintMakerExtendable {
  105. self.description.attributes += .leadingMargin
  106. return self
  107. }
  108. @available(iOS 8.0, *)
  109. public var trailingMargin: ConstraintMakerExtendable {
  110. self.description.attributes += .trailingMargin
  111. return self
  112. }
  113. @available(iOS 8.0, *)
  114. public var centerXWithinMargins: ConstraintMakerExtendable {
  115. self.description.attributes += .centerXWithinMargins
  116. return self
  117. }
  118. @available(iOS 8.0, *)
  119. public var centerYWithinMargins: ConstraintMakerExtendable {
  120. self.description.attributes += .centerYWithinMargins
  121. return self
  122. }
  123. public var edges: ConstraintMakerExtendable {
  124. self.description.attributes += .edges
  125. return self
  126. }
  127. public var horizontalEdges: ConstraintMakerExtendable {
  128. self.description.attributes += .horizontalEdges
  129. return self
  130. }
  131. public var verticalEdges: ConstraintMakerExtendable {
  132. self.description.attributes += .verticalEdges
  133. return self
  134. }
  135. public var directionalEdges: ConstraintMakerExtendable {
  136. self.description.attributes += .directionalEdges
  137. return self
  138. }
  139. public var directionalHorizontalEdges: ConstraintMakerExtendable {
  140. self.description.attributes += .directionalHorizontalEdges
  141. return self
  142. }
  143. public var directionalVerticalEdges: ConstraintMakerExtendable {
  144. self.description.attributes += .directionalVerticalEdges
  145. return self
  146. }
  147. public var size: ConstraintMakerExtendable {
  148. self.description.attributes += .size
  149. return self
  150. }
  151. @available(iOS 8.0, *)
  152. public var margins: ConstraintMakerExtendable {
  153. self.description.attributes += .margins
  154. return self
  155. }
  156. @available(iOS 8.0, *)
  157. public var directionalMargins: ConstraintMakerExtendable {
  158. self.description.attributes += .directionalMargins
  159. return self
  160. }
  161. @available(iOS 8.0, *)
  162. public var centerWithinMargins: ConstraintMakerExtendable {
  163. self.description.attributes += .centerWithinMargins
  164. return self
  165. }
  166. }