Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
#### Added
- Update the `setImage(_:)` method signature.
- Added in Pull Request [#12](https://github.com/space-code/flex-ui/pull/12).
- Implement the `setContentHuggingPriority` & `setContentCompressionResistancePriority` methods.
- Added in Pull Request [#13](https://github.com/space-code/flex-ui/pull/13).

#### 1.x Releases
- `1.3.x` Releases - [1.3.0](#130)
Expand Down
38 changes: 37 additions & 1 deletion Sources/FlexUI/Classes/Extensions/FlexUI+UIView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// flex-ui
// Copyright © 2024 Space Code. All rights reserved.
// Copyright © 2025 Space Code. All rights reserved.
//

import UIKit
Expand Down Expand Up @@ -140,4 +140,40 @@ public extension FlexUI where Component: UIView {
component.alpha = alpha
return self
}

/// Sets the content hugging priority for the specified axis.
/// Content hugging determines how likely the view is to shrink below its intrinsic content size.
/// A higher priority means the view resists growing beyond its content size.
///
/// - Parameters:
/// - priority: The priority value to set.
/// - axis: The axis (`.horizontal` or `.vertical`) on which to apply the priority.
/// - Returns: The current instance, allowing method chaining.
@discardableResult
@MainActor
func setContentHuggingPriority(
_ priority: UILayoutPriority,
for axis: NSLayoutConstraint.Axis
) -> Self {
component.setContentHuggingPriority(priority, for: axis)
return self
}

/// Sets the content compression resistance priority for the specified axis.
/// Compression resistance determines how likely the view is to shrink below its intrinsic content size under compression.
/// A higher priority means the view resists being made smaller than its content size.
///
/// - Parameters:
/// - priority: The priority value to set.
/// - axis: The axis (`.horizontal` or `.vertical`) on which to apply the priority.
/// - Returns: The current instance, allowing method chaining.
@discardableResult
@MainActor
func setContentCompressionResistancePriority(
_ priority: UILayoutPriority,
for axis: NSLayoutConstraint.Axis
) -> Self {
component.setContentCompressionResistancePriority(priority, for: axis)
return self
}
}