one line, truncation.

This commit is contained in:
Kevin G Christiano 2020-01-13 14:31:04 -05:00
parent 0b87ff254b
commit 8ff92b5cc0

View File

@ -8,6 +8,7 @@
import UIKit import UIKit
@objcMembers open class Link: MFCustomButton { @objcMembers open class Link: MFCustomButton {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
@ -62,8 +63,7 @@ import UIKit
context?.move(to: CGPoint(x: x, y: y)) context?.move(to: CGPoint(x: x, y: y))
context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y))
context?.closePath() context?.strokePath()
context?.drawPath(using: .stroke)
} }
//-------------------------------------------------- //--------------------------------------------------
@ -108,9 +108,10 @@ extension Link: MVMCoreViewProtocol {
contentMode = .redraw contentMode = .redraw
setTitleColor(.mfTextButton(), for: .normal) setTitleColor(.mfTextButton(), for: .normal)
setTitleColor(.mfCharcoal(), for: .highlighted) setTitleColor(.mfCharcoal(), for: .highlighted)
titleLabel?.numberOfLines = 1
titleLabel?.lineBreakMode = .byTruncatingTail
titleLabel?.textAlignment = .left titleLabel?.textAlignment = .left
contentHorizontalAlignment = .left contentHorizontalAlignment = .left
titleLabel?.numberOfLines = 1
} }
} }
@ -125,20 +126,19 @@ extension Link: MVMCoreUIMoleculeViewProtocol {
self.additionalData = additionalData self.additionalData = additionalData
self.delegateObject = delegateObject self.delegateObject = delegateObject
guard let unwrappedJson = json else { return } guard let dictionary = json else { return }
actionMap = unwrappedJson actionMap = dictionary
buttonDelegate = delegateObject?.buttonDelegate buttonDelegate = delegateObject?.buttonDelegate
let color = unwrappedJson.stringForkey(KeyTextColor) let color = dictionary.stringForkey(KeyTextColor)
setTitleColor(.mfGet(forHex: color), for: .normal) setTitleColor(.mfGet(forHex: color), for: .normal)
if let title = dictionary.optionalStringForKey(KeyTitle) {
if let title = unwrappedJson.optionalStringForKey(KeyTitle) {
setTitle(title, for: .normal) setTitle(title, for: .normal)
} }
if let enabled = unwrappedJson[KeyEnabled] as? Bool { if let enabled = dictionary[KeyEnabled] as? Bool {
isEnabled = enabled isEnabled = enabled
} }
} }