Commit 9c3c58e6 by Daniel Dahan

development: minor updates to TextField when updating placeholder text color

parent c0b0aa1a
...@@ -465,20 +465,12 @@ extension TextField { ...@@ -465,20 +465,12 @@ extension TextField {
/// Updates the placeholderLabel attributedText. /// Updates the placeholderLabel attributedText.
fileprivate func updatePlaceholderLabelColor() { fileprivate func updatePlaceholderLabelColor() {
guard let v = placeholder else {
return
}
placeholderLabel.textColor = isEditing ? placeholderActiveColor : placeholderNormalColor placeholderLabel.textColor = isEditing ? placeholderActiveColor : placeholderNormalColor
} }
/// Updates the detailLabel attributedText. /// Updates the detailLabel attributedText.
fileprivate func updateDetailLabelColor() { fileprivate func updateDetailLabelColor() {
guard let v = detail else { detailLabel.textColor = detailColor
return
}
detailLabel.attributedText = NSAttributedString(string: v, attributes: [NSForegroundColorAttributeName: detailColor])
} }
} }
...@@ -610,6 +602,8 @@ extension TextField { ...@@ -610,6 +602,8 @@ extension TextField {
/// The animation for the placeholder when editing begins. /// The animation for the placeholder when editing begins.
fileprivate func placeholderEditingDidBeginAnimation() { fileprivate func placeholderEditingDidBeginAnimation() {
updatePlaceholderLabelColor()
guard isPlaceholderAnimated else { guard isPlaceholderAnimated else {
return return
} }
...@@ -618,8 +612,6 @@ extension TextField { ...@@ -618,8 +612,6 @@ extension TextField {
return return
} }
updatePlaceholderLabelColor()
isAnimating = true isAnimating = true
UIView.animate(withDuration: 0.15, animations: { [weak self] in UIView.animate(withDuration: 0.15, animations: { [weak self] in
guard let s = self else { guard let s = self else {
...@@ -644,6 +636,8 @@ extension TextField { ...@@ -644,6 +636,8 @@ extension TextField {
/// The animation for the placeholder when editing ends. /// The animation for the placeholder when editing ends.
fileprivate func placeholderEditingDidEndAnimation() { fileprivate func placeholderEditingDidEndAnimation() {
updatePlaceholderLabelColor()
guard isPlaceholderAnimated else { guard isPlaceholderAnimated else {
return return
} }
...@@ -661,7 +655,6 @@ extension TextField { ...@@ -661,7 +655,6 @@ extension TextField {
s.placeholderLabel.transform = CGAffineTransform.identity s.placeholderLabel.transform = CGAffineTransform.identity
s.placeholderLabel.x = s.leftViewWidth s.placeholderLabel.x = s.leftViewWidth
s.placeholderLabel.y = 0 s.placeholderLabel.y = 0
s.placeholderLabel.textColor = s.placeholderNormalColor
}) { [weak self] _ in }) { [weak self] _ in
self?.isAnimating = false self?.isAnimating = false
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment