@@ -161,7 +161,7 @@ extension UIView {
161
161
/// **Examples:**
162
162
///
163
163
/// To stack two elements with a 10 pt margin between them:
164
- /// ```
164
+ /// ```swift
165
165
/// // This is effectively the same as [ 1.flexible, icon, 10.fixed, label, 1.flexible ].
166
166
/// applyVerticalSubviewDistribution {
167
167
/// icon
@@ -171,7 +171,7 @@ extension UIView {
171
171
/// ```
172
172
///
173
173
/// To evenly spread out items:
174
- /// ```
174
+ /// ```swift
175
175
/// // This is effectively the same as [ 1.flexible, button1, 1.flexible, button2, 1.flexible, button3 ].
176
176
/// applyVerticalSubviewDistribution {
177
177
/// button1
@@ -181,7 +181,7 @@ extension UIView {
181
181
/// ```
182
182
///
183
183
/// To stack two elements with 50% more space below than above:
184
- /// ```
184
+ /// ```swift
185
185
/// applyVerticalSubviewDistribution {
186
186
/// 2.flexible
187
187
/// label
@@ -192,7 +192,7 @@ extension UIView {
192
192
/// ```
193
193
///
194
194
/// To arrange a pair of label on the top and bottom edges of a view, with another label centered between them:
195
- /// ```
195
+ /// ```swift
196
196
/// applyVerticalSubviewDistribution {
197
197
/// 8.fixed
198
198
/// headerLabel
@@ -205,45 +205,45 @@ extension UIView {
205
205
/// ```
206
206
///
207
207
/// To arrange UI in a view with an interior margin:
208
- /// ```
209
- /// applyVerticalSubviewDistribution {
208
+ /// ```swift
209
+ /// applyVerticalSubviewDistribution(inRect: bounds.insetBy(dx: 20, dy: 40)) {
210
210
/// icon
211
211
/// 10.fixed
212
212
/// label
213
- /// }, inRect: bounds.insetBy(dx: 20, dy: 40))
213
+ /// }
214
214
/// ```
215
215
///
216
216
/// To arrange UI vertically aligned by their leading edge 10 pt in from the leading edge of their superview:
217
- /// ```
218
- /// applyVerticalSubviewDistribution {
217
+ /// ```swift
218
+ /// applyVerticalSubviewDistribution(orthogonalOffset: .leading(inset: 10)) {
219
219
/// icon
220
220
/// 1.flexible
221
221
/// button
222
- /// }, orthogonalOffset: .leading(inset: 10))
222
+ /// }
223
223
/// ```
224
224
///
225
225
/// To arrange UI vertically without simultaneously centering it horizontally (the `icon` would need independent
226
226
/// horizontal positioning):
227
- /// ```
228
- /// applyVerticalSubviewDistribution {
227
+ /// ```swift
228
+ /// applyVerticalSubviewDistribution(orthogonalOffset: nil) {
229
229
/// 1.flexible
230
230
/// icon
231
231
/// 2.flexible
232
- /// }, orthogonalOffset: nil)
232
+ /// }
233
233
/// ```
234
234
///
235
235
/// - precondition: All views in the `distribution` must be subviews of the receiver.
236
236
/// - precondition: The `distribution` must not include any given view more than once.
237
237
///
238
- /// - parameter distribution: An array of distribution specifiers, ordered from the top edge to the bottom edge.
239
238
/// - parameter layoutBounds: The region in the receiver in which to distribute the view in the receiver's
240
239
/// coordinate space. Specify `nil` to use the receiver's bounds. Defaults to `nil`.
241
240
/// - parameter orthogonalAlignment: The horizontal alignment to apply to the views. If `nil`, views are left in
242
241
/// their horizontal position prior to the distribution. Defaults to centered with no offset.
242
+ /// - parameter distribution: An array of distribution specifiers, ordered from the top edge to the bottom edge.
243
243
public func applyVerticalSubviewDistribution(
244
- @ViewDistributionBuilder _ distribution: ( ) -> [ ViewDistributionSpecifying ] ,
245
244
inRect layoutBounds: CGRect ? = nil ,
246
- orthogonalAlignment: HorizontalDistributionAlignment ? = . centered( offset: 0 )
245
+ orthogonalAlignment: HorizontalDistributionAlignment ? = . centered( offset: 0 ) ,
246
+ @ViewDistributionBuilder _ distribution: ( ) -> [ ViewDistributionSpecifying ]
247
247
) {
248
248
applyVerticalSubviewDistribution (
249
249
distribution ( ) ,
@@ -343,7 +343,7 @@ extension UIView {
343
343
/// **Examples:**
344
344
///
345
345
/// To stack two elements with a 10 pt margin between them:
346
- /// ```
346
+ /// ```swift
347
347
/// // This is effectively the same as [ 1.flexible, icon, 10.fixed, label, 1.flexible ].
348
348
/// applyHorizontalSubviewDistribution {
349
349
/// icon
@@ -353,7 +353,7 @@ extension UIView {
353
353
/// ```
354
354
///
355
355
/// To evenly spread out items:
356
- /// ```
356
+ /// ```swift
357
357
/// // This is effectively the same as [ 1.flexible, button1, 1.flexible, button2, 1.flexible, button3 ].
358
358
/// applyHorizontalSubviewDistribution {
359
359
/// button1
@@ -363,7 +363,7 @@ extension UIView {
363
363
/// ```
364
364
///
365
365
/// To stack two elements with 50% more space after than before:
366
- /// ```
366
+ /// ```swift
367
367
/// applyHorizontalSubviewDistribution {
368
368
/// 2.flexible
369
369
/// label
@@ -374,7 +374,7 @@ extension UIView {
374
374
/// ```
375
375
///
376
376
/// To arrange a pair of buttons on the left and right edges of a view, with a label centered between them:
377
- /// ```
377
+ /// ```swift
378
378
/// applyHorizontalSubviewDistribution {
379
379
/// 8.fixed
380
380
/// backButton
@@ -387,46 +387,46 @@ extension UIView {
387
387
/// ```
388
388
///
389
389
/// To arrange UI in a view with an interior margin:
390
- /// ```
391
- /// applyHorizontalSubviewDistribution {
390
+ /// ```swift
391
+ /// applyHorizontalSubviewDistribution(inRect: bounds.insetBy(dx: 20, dy: 40)) {
392
392
/// icon
393
393
/// 10.fixed
394
394
/// label
395
- /// }, inRect: bounds.insetBy(dx: 20, dy: 40))
395
+ /// }
396
396
/// ```
397
397
///
398
398
/// To arrange UI horizontally aligned by their top edge 10 pt in from the top edge of their superview:
399
- /// ```
400
- /// applyHorizontalSubviewDistribution {
399
+ /// ```swift
400
+ /// applyHorizontalSubviewDistribution(orthogonalOffset: .top(inset: 10)) {
401
401
/// icon
402
402
/// 1.flexible
403
403
/// button
404
- /// }, orthogonalOffset: .top(inset: 10))
404
+ /// }
405
405
/// ```
406
406
///
407
407
/// To arrange UI horizontally without simultaneously centering it vertically (the `icon` would need independent
408
408
/// vertical positioning):
409
- /// ```
410
- /// applyHorizontalSubviewDistribution {
409
+ /// ```swift
410
+ /// applyHorizontalSubviewDistribution(orthogonalOffset: nil) {
411
411
/// 1.flexible
412
412
/// icon
413
413
/// 2.flexible
414
- /// }, orthogonalOffset: nil)
414
+ /// }
415
415
/// ```
416
416
///
417
417
/// - precondition: All views in the `distribution` must be subviews of the receiver.
418
418
/// - precondition: The `distribution` must not include any given view more than once.
419
419
///
420
- /// - parameter distribution: An array of distribution specifiers, ordered from the leading edge to the trailing
421
- /// edge.
422
420
/// - parameter layoutBounds: The region in the receiver in which to distribute the view in the receiver's
423
421
/// coordinate space. Specify `nil` to use the receiver's bounds. Defaults to `nil`.
424
422
/// - parameter orthogonalAlignment: The vertical alignment to apply to the views. If `nil`, views are left in
425
423
/// their vertical position prior to the distribution. Defaults to centered with no offset.
424
+ /// - parameter distribution: An array of distribution specifiers, ordered from the leading edge to the trailing
425
+ /// edge.
426
426
public func applyHorizontalSubviewDistribution(
427
- @ViewDistributionBuilder _ distribution: ( ) -> [ ViewDistributionSpecifying ] ,
428
427
inRect layoutBounds: CGRect ? = nil ,
429
- orthogonalAlignment: VerticalDistributionAlignment ? = . centered( offset: 0 )
428
+ orthogonalAlignment: VerticalDistributionAlignment ? = . centered( offset: 0 ) ,
429
+ @ViewDistributionBuilder _ distribution: ( ) -> [ ViewDistributionSpecifying ]
430
430
) {
431
431
applyHorizontalSubviewDistribution (
432
432
distribution ( ) ,
0 commit comments