Skip to content

Commit dd62d76

Browse files
committed
Fixed bug raulriera#57 which prevented the textField from animating when assigned a value programmatically
1 parent 06c6bc4 commit dd62d76

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

TextFieldEffects/TextFieldEffects/YoshikoTextField.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ import UIKit
6868
/**
6969
The color of the placeholder text.
7070

71-
This property applies a color to the complete placeholder string. The default value for this property is a black color.
71+
This property applies a color to the complete placeholder string. The default value for this property is a dark gray color.
7272
*/
7373
@IBInspectable dynamic public var placeholderColor: UIColor = .darkGrayColor() {
7474
didSet {
@@ -139,10 +139,14 @@ import UIKit
139139

140140
private func animateViews() {
141141
UIView.animateWithDuration(0.2, animations: {
142-
self.placeholderLabel.alpha = 0
142+
// Prevents a "flash" in the placeholder
143+
if self.text!.isEmpty {
144+
self.placeholderLabel.alpha = 0
145+
}
146+
143147
self.placeholderLabel.frame = self.placeholderRectForBounds(self.bounds)
144148

145-
}) { complete in
149+
}) { complete in
146150
self.updatePlaceholder()
147151
UIView.animateWithDuration(0.3, animations: {
148152
self.placeholderLabel.alpha = 1
@@ -155,14 +159,10 @@ import UIKit
155159
// MARK: - TextFieldEffects
156160

157161
override public func animateViewsForTextEntry() {
158-
guard text!.isEmpty else { return }
159-
160162
animateViews()
161163
}
162164

163165
override public func animateViewsForTextDisplay() {
164-
guard text!.isEmpty else { return }
165-
166166
animateViews()
167167
}
168168

0 commit comments

Comments
 (0)