Skip to content

Commit

Permalink
Fix both floating & inline placeholders being shown when text is cleared
Browse files Browse the repository at this point in the history
Fixes #20
  • Loading branch information
stephsharp committed Jul 15, 2018
1 parent 383be4f commit 425e208
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions MaterialTextField/MFTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,9 @@ - (void)layoutPlaceholderLabelAnimated:(BOOL)animated
{
if (self.shouldShowPlaceholder) {
[self updatePlaceholderColor];

if (self.placeholderIsHidden) {
[self showPlaceholderLabelAnimated:animated];
}
[self showPlaceholderLabelAnimated:animated];
}
else if (!self.placeholderIsHidden) {
else {
[self hidePlaceholderLabelAnimated:animated];
}
}
Expand Down Expand Up @@ -423,6 +420,10 @@ - (void)showPlaceholderLabelAnimated:(BOOL)animated
// Call setPlaceholder on super so placeholderAttributedString is not set to nil
[super setPlaceholder:nil];
}

if (!self.placeholderIsHidden) {
return;
}

if (animated && !self.placeholderIsAnimating) {
[self.superview layoutIfNeeded];
Expand Down Expand Up @@ -452,6 +453,10 @@ - (void)showPlaceholderLabelAnimated:(BOOL)animated

- (void)hidePlaceholderLabelAnimated:(BOOL)animated
{
if (self.placeholderIsHidden) {
return;
}

CGFloat finalDistanceFromTop = CGRectGetMinY(self.textRect) / 2.0f;

if (self.placeholderAnimatesOnFocus) {
Expand Down

0 comments on commit 425e208

Please sign in to comment.