enabled/disabled colors.
This commit is contained in:
parent
edddac84a8
commit
8490ef3572
@ -16,6 +16,15 @@ import UIKit
|
|||||||
|
|
||||||
private var additionalData: [AnyHashable: Any]?
|
private var additionalData: [AnyHashable: Any]?
|
||||||
|
|
||||||
|
public var titleColor: (enabled: UIColor?, disabled: UIColor?) = (.mfTextButton(), .mfSilver())
|
||||||
|
|
||||||
|
public override var isEnabled: Bool {
|
||||||
|
didSet {
|
||||||
|
setTitleColor(isEnabled ? titleColor.enabled : titleColor.disabled, for: .normal)
|
||||||
|
setNeedsDisplay()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Delegate
|
// MARK: - Delegate
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -50,7 +59,7 @@ import UIKit
|
|||||||
|
|
||||||
let context = UIGraphicsGetCurrentContext()
|
let context = UIGraphicsGetCurrentContext()
|
||||||
|
|
||||||
// Set to the same color as the text
|
// Set line to the same color as the text
|
||||||
if let color = titleLabel?.textColor?.cgColor {
|
if let color = titleLabel?.textColor?.cgColor {
|
||||||
context?.setStrokeColor(color)
|
context?.setStrokeColor(color)
|
||||||
}
|
}
|
||||||
@ -108,6 +117,7 @@ extension Link: MVMCoreViewProtocol {
|
|||||||
contentMode = .redraw
|
contentMode = .redraw
|
||||||
setTitleColor(.mfTextButton(), for: .normal)
|
setTitleColor(.mfTextButton(), for: .normal)
|
||||||
setTitleColor(.mfCharcoal(), for: .highlighted)
|
setTitleColor(.mfCharcoal(), for: .highlighted)
|
||||||
|
titleColor = (.mfTextButton(), .mfSilver())
|
||||||
titleLabel?.numberOfLines = 1
|
titleLabel?.numberOfLines = 1
|
||||||
titleLabel?.lineBreakMode = .byTruncatingTail
|
titleLabel?.lineBreakMode = .byTruncatingTail
|
||||||
titleLabel?.textAlignment = .left
|
titleLabel?.textAlignment = .left
|
||||||
@ -125,14 +135,15 @@ extension Link: MVMCoreUIMoleculeViewProtocol {
|
|||||||
public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
self.additionalData = additionalData
|
self.additionalData = additionalData
|
||||||
self.delegateObject = delegateObject
|
self.delegateObject = delegateObject
|
||||||
|
buttonDelegate = delegateObject?.buttonDelegate
|
||||||
|
|
||||||
guard let dictionary = json else { return }
|
guard let dictionary = json else { return }
|
||||||
actionMap = dictionary
|
actionMap = dictionary
|
||||||
|
|
||||||
buttonDelegate = delegateObject?.buttonDelegate
|
if let colorHex = dictionary[KeyTextColor] as? String {
|
||||||
|
titleColor.enabled = .mfGet(forHex: colorHex)
|
||||||
let color = dictionary.stringForkey(KeyTextColor)
|
setTitleColor(titleColor.enabled, for: .normal)
|
||||||
setTitleColor(.mfGet(forHex: color), for: .normal)
|
}
|
||||||
|
|
||||||
if let title = dictionary.optionalStringForKey(KeyTitle) {
|
if let title = dictionary.optionalStringForKey(KeyTitle) {
|
||||||
setTitle(title, for: .normal)
|
setTitle(title, for: .normal)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user