Fixed setWithJSON, allows it to work properly with Atom molecule. Provided more properties to control.

This commit is contained in:
Christiano, Kevin 2019-04-01 13:30:31 -04:00
parent de0c031b7f
commit 499f9eb55d

View File

@ -112,9 +112,7 @@ open class CaretButton: MFCustomButton {
}
@objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
// Configure class properties with JSON values
guard let jsonDictionary = json else { return }
if let backgroundColorHex = jsonDictionary[KeyBackgroundColor] as? String {
@ -128,5 +126,17 @@ open class CaretButton: MFCustomButton {
if let disabledColorHex = jsonDictionary["disabledColor"] as? String {
disabledColor = UIColor.mfGet(forHex: disabledColorHex)
}
if let caretViewHeight = jsonDictionary["caretViewHeight"] as? NSNumber {
rightViewHeight = caretViewHeight
}
if let caretViewWidth = jsonDictionary["caretViewWidth"] as? NSNumber {
rightViewWidth = caretViewWidth
}
if let buttonText = jsonDictionary["buttonText"] as? String {
setTitle(buttonText, for: .normal)
}
}
}