From cfe0f6135b2e20604e296fe581b34bc44c253bae Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 23 Aug 2023 09:54:24 -0500 Subject: [PATCH] revert back to original Signed-off-by: Matt Bruce --- .../Buttons/TextLink/TextLink.swift | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/VDS/Components/Buttons/TextLink/TextLink.swift b/VDS/Components/Buttons/TextLink/TextLink.swift index e0856e83..b4d8a745 100644 --- a/VDS/Components/Buttons/TextLink/TextLink.swift +++ b/VDS/Components/Buttons/TextLink/TextLink.swift @@ -18,6 +18,10 @@ open class TextLink: ButtonBase { // MARK: - Private Properties //-------------------------------------------------- private var lineHeightConstraint: NSLayoutConstraint? + + private var line = UIView().with { + $0.translatesAutoresizingMaskIntoConstraints = false + } //-------------------------------------------------- // MARK: - Properties @@ -72,7 +76,13 @@ open class TextLink: ButtonBase { isAccessibilityElement = true accessibilityTraits = .link if let titleLabel { - titleLabel.debugBorder(show: true) + addSubview(line) + line.pinLeading(titleLabel.leadingAnchor) + line.pinTrailing(titleLabel.trailingAnchor) + line.pinTop(titleLabel.bottomAnchor) + line.pinBottom(bottomAnchor, 0, .defaultHigh) + lineHeightConstraint = line.heightAnchor.constraint(equalToConstant: 1.0) + lineHeightConstraint?.isActive = true } } @@ -81,7 +91,7 @@ open class TextLink: ButtonBase { super.reset() shouldUpdateView = false text = nil - size = .large + size = .large accessibilityCustomActions = [] isAccessibilityElement = true accessibilityTraits = .link @@ -95,9 +105,14 @@ open class TextLink: ButtonBase { open override var intrinsicContentSize: CGSize { return titleLabel?.intrinsicContentSize ?? super.intrinsicContentSize } + + /// Function used to make changes to the View based off a change events or from local properties. + open override func updateView() { + //need to set the properties so the super class + //can render out the label correctly + line.backgroundColor = textColor - open override func layoutSubviews() { - super.layoutSubviews() - addBorder(side: .bottom, width: 1, color: textColor) + //always call last so the label is rendered + super.updateView() } }