diff --git a/Sources/SkyFloatingLabelTextField.swift b/Sources/SkyFloatingLabelTextField.swift index 0578e8e..2e9e926 100644 --- a/Sources/SkyFloatingLabelTextField.swift +++ b/Sources/SkyFloatingLabelTextField.swift @@ -113,6 +113,20 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty updateTitleColor() } } + + /// A UIColor value that determines the border color of the textField when in the normal state + @IBInspectable dynamic open var borderColor: UIColor = .gray { + didSet { + updateBorderColor() + } + } + + /// A UIColor value that determines the border color of the textField when in the selected state + @IBInspectable dynamic open var selectedBorderColor: UIColor = .gray { + didSet { + updateBorderColor() + } + } /// A UIColor value that determines the color of the bottom line when in the normal state @IBInspectable dynamic open var lineColor: UIColor = .lightGray { @@ -467,6 +481,20 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty } } } + + fileprivate func updateBorderColor() { + if !isEnabled { + self.layer.borderColor = borderColor.cgColor + } else if hasErrorMessage { + self.layer.borderColor = borderColor.cgColor + } else { + if editingOrSelected || isHighlighted { + self.layer.borderColor = selectedBorderColor.cgColor + } else { + self.layer.borderColor = borderColor.cgColor + } + } + } fileprivate func updateTextColor() { if !isEnabled {