diff --git a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldTests.swift b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldTests.swift index 33020c2..1d60aed 100644 --- a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldTests.swift +++ b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldTests.swift @@ -57,7 +57,7 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ NSRange(location: 0, length: floatingLabelTextField.placeholder!.count) #else var fullRange = - NSRange(location: 0, length: floatingLabelTextField.placeholder!.characters.count) + NSRange(location: 0, length: floatingLabelTextField.placeholder!.count) #endif // when @@ -236,7 +236,7 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ NSRange(location: 0, length: floatingLabelTextField.placeholder!.count) #else var fullRange = - NSRange(location: 0, length: floatingLabelTextField.placeholder!.characters.count) + NSRange(location: 0, length: floatingLabelTextField.placeholder!.count) #endif // when @@ -298,7 +298,7 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ NSRange(location: 0, length: floatingLabelTextField.placeholder!.count) #else var fullRange = - NSRange(location: 0, length: floatingLabelTextField.placeholder!.characters.count) + NSRange(location: 0, length: floatingLabelTextField.placeholder!.count) #endif // when @@ -351,7 +351,7 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ NSRange(location: 0, length: floatingLabelTextField.placeholder!.count) #else var fullRange = - NSRange(location: 0, length: floatingLabelTextField.placeholder!.characters.count) + NSRange(location: 0, length: floatingLabelTextField.placeholder!.count) #endif // when diff --git a/Sources/SkyFloatingLabelTextField.swift b/Sources/SkyFloatingLabelTextField.swift index ad55ffe..5336145 100644 --- a/Sources/SkyFloatingLabelTextField.swift +++ b/Sources/SkyFloatingLabelTextField.swift @@ -37,20 +37,11 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty } fileprivate func updateTextAligment() { - if isLTRLanguage { - textAlignment = .left - titleLabel.textAlignment = .left - errorLabel.textAlignment = .left - } else { - textAlignment = .right - titleLabel.textAlignment = .right - errorLabel.textAlignment = .right - } - // Override error message default alignment - if let errorLabelAlignment = errorLabelAlignment { - errorLabel.textAlignment = errorLabelAlignment - } + let alignment: NSTextAlignment = isLTRLanguage ? .left : .right + textAlignment = alignment + titleLabel.textAlignment = alignment + errorLabel.textAlignment = alignment } // MARK: Animation timing @@ -101,7 +92,8 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty /// An `NSTextAlignment` value that determines the error label text alignment. open var errorLabelAlignment: NSTextAlignment? { didSet { - updateTextAligment() + // Override error message default alignment + errorLabel.textAlignment = errorLabelAlignment } } @@ -422,7 +414,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty fileprivate func configureDefaultLineHeight() { let onePixel: CGFloat = 1.0 / UIScreen.main.scale lineHeight = 2.0 * onePixel - selectedLineHeight = 2.0 * self.lineHeight + selectedLineHeight = 2.0 * lineHeight } // MARK: Responder handling