Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Sources/SkyFloatingLabelTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down