From 740e757fe4fb23e3c06ec88b55009e774b9626a8 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 10 Feb 2021 13:53:58 -0500 Subject: [PATCH] undelrine didn't show when rotating --- .../Atomic/Atoms/Buttons/Link/Link.swift | 30 ++++++++----------- .../Atomic/Atoms/Buttons/Link/LinkModel.swift | 4 +-- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 9ced5f5a..04140d6e 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -11,18 +11,18 @@ import UIKit @objcMembers open class Link: Button { //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Draw //-------------------------------------------------- open override func draw(_ rect: CGRect) { - guard let textRect = titleLabel?.frame else { return } - - let context = UIGraphicsGetCurrentContext() + guard let textRect = titleLabel?.frame, + let context = UIGraphicsGetCurrentContext() + else { return } // Set line to the same color as the text if let color = titleLabel?.textColor?.cgColor { - context?.setStrokeColor(color) + context.setStrokeColor(color) } // x should be according to the text, not the button @@ -31,9 +31,9 @@ import UIKit // Line is 1 point below the text let y = textRect.origin.y + textRect.size.height + 1 - context?.move(to: CGPoint(x: x, y: y)) - context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) - context?.strokePath() + context.move(to: CGPoint(x: x, y: y)) + context.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) + context.strokePath() } open override var intrinsicContentSize: CGSize { @@ -67,16 +67,12 @@ extension Link { open override func updateView(_ size: CGFloat) { super.updateView(size) - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - - var width = size - if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) { - width = MVMCoreUIUtility.getWidth() - } - - self.titleLabel?.font = MFStyler.fontB2(forWidth: width) + var width = size + if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) { + width = MVMCoreUIUtility.getWidth() } + + titleLabel?.font = MFStyler.fontB2(forWidth: width) } open override func setupView() { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 4519b030..f3b48bd4 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -14,9 +14,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode // MARK: - Properties //-------------------------------------------------- - public class var identifier: String { - return "link" - } + public class var identifier: String { "link" } public var backgroundColor: Color? public var accessibilityIdentifier: String?