Skip to content

Commit 1116868

Browse files
OlegOleg
authored andcommitted
Minor code improvements.
1 parent 6902cec commit 1116868

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Sources/TweePlaceholderTextField.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,13 @@ public class TweePlaceholderTextField: UITextField {
5757

5858
public override var text: String? {
5959
didSet {
60-
if let text = text, text.isEmpty == false {
61-
minimizePlaceholder()
62-
}
60+
setCorrectPlaceholderSize()
6361
}
6462
}
6563

6664
public override var attributedText: NSAttributedString? {
6765
didSet {
68-
if let attrText = attributedText, attrText.string.isEmpty == false {
69-
minimizePlaceholder()
70-
}
66+
setCorrectPlaceholderSize()
7167
}
7268
}
7369

@@ -119,6 +115,14 @@ public class TweePlaceholderTextField: UITextField {
119115
object: self)
120116
}
121117

118+
@objc private func setCorrectPlaceholderSize() {
119+
if let text = text, text.isEmpty == false {
120+
minimizePlaceholder()
121+
} else if isEditing == false {
122+
maximizePlaceholder()
123+
}
124+
}
125+
122126
@objc private func minimizePlaceholder() {
123127
bottomConstraint?.constant = -frame.height
124128

TweeTextField.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Pod::Spec.new do |s|
66
s.name = 'TweeTextField'
7-
s.version = '1.0.1'
7+
s.version = '1.0.2'
88
s.summary = 'Lightweight set of attributed text fields with nice animation'
99
s.description = <<-DESC
1010
This is lightweight library that provides different types of Text Fields based on your needs. I was inspired by https://uimovement.com/ui/2524/input-field-help/.

0 commit comments

Comments
 (0)