Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.

Commit 9c50bbe

Browse files
author
Hugo Tunius
committed
[Crash] Prevent rare crash
1 parent 273a199 commit 9c50bbe

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Master
22
------
33

4+
* Prevent potential crash when `self.font` is `nil`. This might cause the component to render incorrectly, but it will not crash which is preferable. See [#186](https://github.com/Skyscanner/SkyFloatingLabelTextField/issues/186)
5+
46
v3.5.0
57
------
68

Sources/SkyFloatingLabelTextField.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,11 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
625625
-returns: the calculated height of the textfield. Override to size the textfield with a different height
626626
*/
627627
open func textHeight() -> CGFloat {
628-
return self.font!.lineHeight + 7.0
628+
guard let font = self.font else {
629+
return 0.0
630+
}
631+
632+
return font.lineHeight + 7.0;
629633
}
630634

631635
// MARK: - Layout

0 commit comments

Comments
 (0)