Skip to content

Commit d1b2174

Browse files
authored
Implement the setContentHuggingPriority & setContentCompressionResistancePriority methods (#13)
* Implement the `setContentHuggingPriority` & `setContentCompressionResistancePriority` methods * Update `CHANGELOG.md`
1 parent d0add59 commit d1b2174

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
66
#### Added
77
- Update the `setImage(_:)` method signature.
88
- Added in Pull Request [#12](https://github.com/space-code/flex-ui/pull/12).
9+
- Implement the `setContentHuggingPriority` & `setContentCompressionResistancePriority` methods.
10+
- Added in Pull Request [#13](https://github.com/space-code/flex-ui/pull/13).
911

1012
#### 1.x Releases
1113
- `1.3.x` Releases - [1.3.0](#130)

Sources/FlexUI/Classes/Extensions/FlexUI+UIView.swift

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// flex-ui
3-
// Copyright © 2024 Space Code. All rights reserved.
3+
// Copyright © 2025 Space Code. All rights reserved.
44
//
55

66
import UIKit
@@ -140,4 +140,40 @@ public extension FlexUI where Component: UIView {
140140
component.alpha = alpha
141141
return self
142142
}
143+
144+
/// Sets the content hugging priority for the specified axis.
145+
/// Content hugging determines how likely the view is to shrink below its intrinsic content size.
146+
/// A higher priority means the view resists growing beyond its content size.
147+
///
148+
/// - Parameters:
149+
/// - priority: The priority value to set.
150+
/// - axis: The axis (`.horizontal` or `.vertical`) on which to apply the priority.
151+
/// - Returns: The current instance, allowing method chaining.
152+
@discardableResult
153+
@MainActor
154+
func setContentHuggingPriority(
155+
_ priority: UILayoutPriority,
156+
for axis: NSLayoutConstraint.Axis
157+
) -> Self {
158+
component.setContentHuggingPriority(priority, for: axis)
159+
return self
160+
}
161+
162+
/// Sets the content compression resistance priority for the specified axis.
163+
/// Compression resistance determines how likely the view is to shrink below its intrinsic content size under compression.
164+
/// A higher priority means the view resists being made smaller than its content size.
165+
///
166+
/// - Parameters:
167+
/// - priority: The priority value to set.
168+
/// - axis: The axis (`.horizontal` or `.vertical`) on which to apply the priority.
169+
/// - Returns: The current instance, allowing method chaining.
170+
@discardableResult
171+
@MainActor
172+
func setContentCompressionResistancePriority(
173+
_ priority: UILayoutPriority,
174+
for axis: NSLayoutConstraint.Axis
175+
) -> Self {
176+
component.setContentCompressionResistancePriority(priority, for: axis)
177+
return self
178+
}
143179
}

0 commit comments

Comments
 (0)