diff --git a/Classes/UIButtons/DCBaseButton.swift b/Classes/UIButtons/DCBaseButton.swift index 15ca379..fa326db 100644 --- a/Classes/UIButtons/DCBaseButton.swift +++ b/Classes/UIButtons/DCBaseButton.swift @@ -52,7 +52,13 @@ public class DCBaseButton: UIButton { updateColor() } } - + + @IBInspectable public var highlightedBackgroundColor: UIColor = UIColor(red: 37.0/255.0, green: 147.0/255.0, blue: 1.0/255.0, alpha: 1.0) { + didSet { + updateColor() + } + } + override public var enabled: Bool { didSet { updateColor() @@ -64,7 +70,13 @@ public class DCBaseButton: UIButton { updateColor() } } - + + override public var highlighted: Bool { + didSet { + updateColor() + } + } + // MARK: - Initializers override public init(frame: CGRect) { @@ -96,7 +108,15 @@ public class DCBaseButton: UIButton { // MARK: - Misc public func updateColor() { - backgroundColor = enabled ? (selected ? selectedBackgroundColor : normalBackgroundColor) : disabledBackgroundColor + if (enabled==false){ + backgroundColor = disabledBackgroundColor + } else if (selected==true){ + backgroundColor = selectedBackgroundColor + } else if (highlighted==true){ + backgroundColor = highlightedBackgroundColor + } else { + backgroundColor = normalBackgroundColor + } } } diff --git a/Classes/UIButtons/DCBorderedButton.swift b/Classes/UIButtons/DCBorderedButton.swift index 49679b0..273a037 100644 --- a/Classes/UIButtons/DCBorderedButton.swift +++ b/Classes/UIButtons/DCBorderedButton.swift @@ -34,7 +34,13 @@ public class DCBorderedButton: DCBaseButton { updateColor() } } - + + @IBInspectable public var highlightedBorderColor: UIColor = UIColor(red: 37.0/255.0, green: 147.0/255.0, blue: 1.0/255.0, alpha: 1.0) { + didSet { + updateColor() + } + } + @IBInspectable public var cornerRadius: CGFloat { get { return layer.cornerRadius @@ -87,7 +93,15 @@ public class DCBorderedButton: DCBaseButton { override public func updateColor() { super.updateColor() - layer.borderColor = enabled ? (selected ? selectedBorderColor.CGColor : normalBorderColor.CGColor) : disabledBorderColor.CGColor + if (enabled==false){ + layer.borderColor = disabledBorderColor.CGColor + } else if (selected==true){ + layer.borderColor = selectedBorderColor.CGColor + } else if (highlighted==true){ + layer.borderColor = highlightedBorderColor.CGColor + } else { + layer.borderColor = normalBorderColor.CGColor + } } - + }