|
1 | 1 | // |
2 | 2 | // flex-ui |
3 | | -// Copyright © 2024 Space Code. All rights reserved. |
| 3 | +// Copyright © 2025 Space Code. All rights reserved. |
4 | 4 | // |
5 | 5 |
|
6 | 6 | import UIKit |
@@ -140,4 +140,40 @@ public extension FlexUI where Component: UIView { |
140 | 140 | component.alpha = alpha |
141 | 141 | return self |
142 | 142 | } |
| 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 | + } |
143 | 179 | } |
0 commit comments