update method to set text

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-03-13 08:59:39 -05:00
parent b258608b77
commit 3c375bea39

View File

@ -61,7 +61,7 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
open var surface: Surface = .light { didSet { setNeedsUpdate() } } open var surface: Surface = .light { didSet { setNeedsUpdate() } }
/// Text that will be used in the titleLabel. /// Text that will be used in the titleLabel.
open var text: String? { didSet { setNeedsUpdate() } } open var text: String? { didSet { textSetMode = .text; setNeedsUpdate() } }
/// Array of LabelAttributeModel objects used in rendering the text. /// Array of LabelAttributeModel objects used in rendering the text.
open var textAttributes: [any LabelAttributeModel]? { nil } open var textAttributes: [any LabelAttributeModel]? { nil }
@ -163,8 +163,7 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
override public func setTitle(_ title: String?, for state: UIControl.State) { override public func setTitle(_ title: String?, for state: UIControl.State) {
// When text is set, we may need to re-style it as attributedText // When text is set, we may need to re-style it as attributedText
// with the correct paragraph style to achieve the desired line height. // with the correct paragraph style to achieve the desired line height.
textSetMode = .text text = title
styleText(title, for: state)
} }
/// :nodoc: /// :nodoc: