Skip to content

Commit eb1d112

Browse files
committed
Merge commit '1116868cae88f65237addc0d5cdbddc257374549'
2 parents dd94c8e + 1116868 commit eb1d112

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Sources/TweePlaceholderTextField.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ open class TweePlaceholderTextField: UITextField {
5555
/// Custom placeholder label. You can use it to style placeholder text.
5656
public private(set) lazy var placeholderLabel = UILabel()
5757

58+
public override var text: String? {
59+
didSet {
60+
setCorrectPlaceholderSize()
61+
}
62+
}
63+
64+
public override var attributedText: NSAttributedString? {
65+
didSet {
66+
setCorrectPlaceholderSize()
67+
}
68+
}
69+
5870
// Private
5971

6072
private var minimizeFontAnimation: FontAnimation!
@@ -103,6 +115,14 @@ open class TweePlaceholderTextField: UITextField {
103115
object: self)
104116
}
105117

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+
106126
@objc private func minimizePlaceholder() {
107127
bottomConstraint?.constant = -frame.height
108128

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.0'
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/.

TweeTextField/ViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ final class ViewController: UIViewController {
2222

2323
override func viewDidLoad() {
2424
super.viewDidLoad()
25+
usernameTextField.text = "text"
2526
}
2627

2728
@IBAction private func confirm() {

0 commit comments

Comments
 (0)