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
22 changes: 21 additions & 1 deletion Sources/SkyFloatingLabelTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
// MARK: Colors

fileprivate var cachedTextColor: UIColor?
fileprivate var cachedAttributedText: NSAttributedString?

/// A UIColor value that determines the text color of the editable text
@IBInspectable
Expand All @@ -76,6 +77,21 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
}
}

/// An `NSAttributedString` to display as the text field content
///
/// **NOTE:** by setting this property to a non-nil value, changes to `textColor`
/// are ignored.
@IBInspectable
override dynamic open var attributedText: NSAttributedString? {
set {
cachedAttributedText = newValue
super.attributedText = newValue
}
get {
return cachedAttributedText
}
}

/// A UIColor value that determines text color of the placeholder label
@IBInspectable dynamic open var placeholderColor: UIColor = UIColor.lightGray {
didSet {
Expand Down Expand Up @@ -526,7 +542,11 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
} else if hasErrorMessage {
super.textColor = textErrorColor ?? errorColor
} else {
super.textColor = cachedTextColor
if let attributedText = cachedAttributedText {
super.attributedText = attributedText
} else {
super.textColor = cachedTextColor
}
}
}

Expand Down