@@ -56,6 +56,22 @@ extension UIView {
56
56
57
57
// MARK: - Size
58
58
59
+ /// Creates constraints defining the size of the receiver.
60
+ ///
61
+ /// - Parameter size: The constant size value. When `nil`, the size of the receiver is used.
62
+ ///
63
+ /// - Returns: The created constraints.
64
+ public func sizeConstraints(
65
+ _ size: CGSize ? = nil
66
+ ) -> [ NSLayoutConstraint ] {
67
+ [
68
+ width. constraint ( size? . width ?? bounds. width) ,
69
+ height. constraint ( size? . height ?? bounds. height)
70
+ ]
71
+ }
72
+
73
+ // MARK: - Width
74
+
59
75
/// Creates a constraint defining the width of the receiver.
60
76
///
61
77
/// - Parameters:
@@ -81,6 +97,8 @@ extension UIView {
81
97
width. constraint ( constant ?? bounds. width)
82
98
}
83
99
100
+ // MARK: - Height
101
+
84
102
/// Creates a constraint defining the height of the receiver.
85
103
///
86
104
/// - Parameters:
@@ -106,21 +124,7 @@ extension UIView {
106
124
height. constraint ( constant ?? bounds. height)
107
125
}
108
126
109
- /// Creates constraints defining the size of the receiver.
110
- ///
111
- /// - Parameter size: The constant size value. When `nil`, the size of the receiver is used.
112
- ///
113
- /// - Returns: The created constraints.
114
- public func sizeConstraints(
115
- _ size: CGSize ? = nil
116
- ) -> [ NSLayoutConstraint ] {
117
- [
118
- width. constraint ( size? . width ?? bounds. width) ,
119
- height. constraint ( size? . height ?? bounds. height)
120
- ]
121
- }
122
-
123
- // MARK: - Aspect Ratio
127
+ // MARK: - Square
124
128
125
129
/// Creates a constraint defining the aspect ratio of the receiver to be square.
126
130
///
@@ -129,6 +133,8 @@ extension UIView {
129
133
constraint ( for: . width, to: . height, of: self )
130
134
}
131
135
136
+ // MARK: - Aspect Ratio
137
+
132
138
/// Creates a constraint defining the aspect ratio of the receiver.
133
139
///
134
140
/// - Parameter ratio: The aspect ratio.
0 commit comments