Skip to content

Commit 7fbc85d

Browse files
authored
Implement a new setImage method for the UIButton class (#9)
* Implement a new `setImage` method for the `UIButton` class * Update `CHANGELOG.md`
1 parent 6775c51 commit 7fbc85d

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44
## [Unreleased]
55

66
#### Added
7+
- Implement a new `setImage` method for the `UIButton` class.
8+
- Added in Pull Request [#9](https://github.com/space-code/flex-ui/pull/9).
79
- Implement setting an optional value as the UILabel's text.
810
- Added in Pull Request [#8](https://github.com/space-code/flex-ui/pull/8).
911

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,17 @@ public extension FlexUI where Component: UIButton {
205205
component.isEnabled = isEnable
206206
return self
207207
}
208+
209+
/// Sets the image for a specific button state.
210+
///
211+
/// - Parameters:
212+
/// - image: The image to set.
213+
/// - controlState: The state for which to set the background image (default is `.normal`).
214+
/// - Returns: The current instance of `FlexUI` for further configuration.
215+
@discardableResult
216+
@MainActor
217+
func setImage(_ image: UIImage, for controlState: UIControl.State = .normal) -> Self {
218+
component.setImage(image, for: controlState)
219+
return self
220+
}
208221
}

0 commit comments

Comments
 (0)