From b4b340f8886a59448f1f0471ab9577d76a3c2506 Mon Sep 17 00:00:00 2001 From: Bogi Date: Fri, 14 May 2021 13:30:50 +0200 Subject: [PATCH 1/2] added test that is failing with flickering bug --- .../JVFloatLabeledTextFieldTests.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/JVFloatLabeledTextFieldTests/JVFloatLabeledTextFieldTests.m b/JVFloatLabeledTextFieldTests/JVFloatLabeledTextFieldTests.m index eb47db3..3501fe0 100644 --- a/JVFloatLabeledTextFieldTests/JVFloatLabeledTextFieldTests.m +++ b/JVFloatLabeledTextFieldTests/JVFloatLabeledTextFieldTests.m @@ -89,4 +89,15 @@ - (void)testKeepBaseline XCTAssert(CGRectEqualToRect(clearRectInitial, clearRectFinal)); } +-(void)testIntrinsicContentHeight +{ + self.testField.text = @"foo"; + CGFloat firstHeight = self.testField.intrinsicContentSize.height; + + self.testField.text = @"bar"; + CGFloat secondHeight = self.testField.intrinsicContentSize.height; + + XCTAssertEqual(firstHeight, secondHeight); +} + @end From 04ba76d8c53eafda3496ddbb9d588d6998ed7172 Mon Sep 17 00:00:00 2001 From: Bogi Date: Fri, 14 May 2021 13:34:09 +0200 Subject: [PATCH 2/2] fixed the flickering bug by removing CGRectIntegral which was not behaving deterministically --- .../JVFloatLabeledTextField/JVFloatLabeledTextField.m | 6 +++--- .../JVFloatLabeledTextField/JVFloatLabeledTextView.m | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/JVFloatLabeledTextField/JVFloatLabeledTextField/JVFloatLabeledTextField.m b/JVFloatLabeledTextField/JVFloatLabeledTextField/JVFloatLabeledTextField.m index ac13fb8..4e0b76b 100644 --- a/JVFloatLabeledTextField/JVFloatLabeledTextField/JVFloatLabeledTextField.m +++ b/JVFloatLabeledTextField/JVFloatLabeledTextField/JVFloatLabeledTextField.m @@ -283,7 +283,7 @@ - (CGRect)textRectForBounds:(CGRect)bounds if ([self.text length] || self.keepBaseline) { rect = [self insetRectForBounds:rect]; } - return CGRectIntegral(rect); + return rect; } - (CGRect)editingRectForBounds:(CGRect)bounds @@ -292,7 +292,7 @@ - (CGRect)editingRectForBounds:(CGRect)bounds if ([self.text length] || self.keepBaseline) { rect = [self insetRectForBounds:rect]; } - return CGRectIntegral(rect); + return rect; } - (CGRect)insetRectForBounds:(CGRect)rect @@ -314,7 +314,7 @@ - (CGRect)clearButtonRectForBounds:(CGRect)bounds rect = CGRectMake(rect.origin.x, rect.origin.y + topInset / 2.0f, rect.size.width, rect.size.height); } } - return CGRectIntegral(rect); + return rect; } - (CGRect)leftViewRectForBounds:(CGRect)bounds diff --git a/JVFloatLabeledTextField/JVFloatLabeledTextField/JVFloatLabeledTextView.m b/JVFloatLabeledTextField/JVFloatLabeledTextField/JVFloatLabeledTextView.m index 47ac618..7e4bebd 100644 --- a/JVFloatLabeledTextField/JVFloatLabeledTextField/JVFloatLabeledTextView.m +++ b/JVFloatLabeledTextField/JVFloatLabeledTextField/JVFloatLabeledTextView.m @@ -340,7 +340,7 @@ - (CGRect)textRect rect.origin.y += self.textContainerInset.top; } - return CGRectIntegral(rect); + return rect; } - (void)setFloatingLabelFont:(UIFont *)floatingLabelFont