From 8ff92b5cc0b44762e6c067fa0a917ef476f1c367 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 13 Jan 2020 14:31:04 -0500 Subject: [PATCH] one line, truncation. --- MVMCoreUI/Atoms/Buttons/Link.swift | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 394807b6..4a23281b 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -8,6 +8,7 @@ import UIKit + @objcMembers open class Link: MFCustomButton { //-------------------------------------------------- // MARK: - Properties @@ -62,8 +63,7 @@ import UIKit context?.move(to: CGPoint(x: x, y: y)) context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) - context?.closePath() - context?.drawPath(using: .stroke) + context?.strokePath() } //-------------------------------------------------- @@ -77,7 +77,7 @@ import UIKit // MARK: - AppleGuidelinesProtocol extension Link: AppleGuidelinesProtocol { - + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { return Self.acceptablyOutsideBounds(point: point, bounds: bounds) @@ -108,9 +108,10 @@ extension Link: MVMCoreViewProtocol { contentMode = .redraw setTitleColor(.mfTextButton(), for: .normal) setTitleColor(.mfCharcoal(), for: .highlighted) + titleLabel?.numberOfLines = 1 + titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left contentHorizontalAlignment = .left - titleLabel?.numberOfLines = 1 } } @@ -125,20 +126,19 @@ extension Link: MVMCoreUIMoleculeViewProtocol { self.additionalData = additionalData self.delegateObject = delegateObject - guard let unwrappedJson = json else { return } - actionMap = unwrappedJson + guard let dictionary = json else { return } + actionMap = dictionary buttonDelegate = delegateObject?.buttonDelegate - let color = unwrappedJson.stringForkey(KeyTextColor) + let color = dictionary.stringForkey(KeyTextColor) setTitleColor(.mfGet(forHex: color), for: .normal) - - if let title = unwrappedJson.optionalStringForKey(KeyTitle) { + if let title = dictionary.optionalStringForKey(KeyTitle) { setTitle(title, for: .normal) } - if let enabled = unwrappedJson[KeyEnabled] as? Bool { + if let enabled = dictionary[KeyEnabled] as? Bool { isEnabled = enabled } }