SkyFloatingLabelTextField
SkyFloatingLabelTextField copied to clipboard
Text's end is hidden when it get the field's width limit
When I'm typing the text on the field and it get at the end of the field, the string keeps increasing, but visually the text is hidden.
If I press the left arrow on the keyboard (<-) to back positions on the text, the hidden piece of string is shown.
I have already tested in a real device and I'm getting the same error.
I expect that the text become visible while we are typing, even if the field's width be overflown.
This image represents the moment that I was typing without stopping.
And this image represents when I stop typing and press the left arrow key (<-).
Environment
Xcode Version: 9.4 SkyFloatingLabelTextField Version: 3.6 Deployment Target: iPhone 6 and iPhone 8 Method of Integration: CocoaPods
I think that is not the better solution, but I solved the problem by creating the following function:
func putCaretAtTheEnd()
{
if(selectedTextRange?.end == endOfDocument)
{
let arbitraryValue: Int = text!.count - 1
if let newPosition = position(from: beginningOfDocument, offset: arbitraryValue) {
selectedTextRange = textRange(from: newPosition, to: newPosition)
textAlignment = .left
}
let arbitraryValue2: Int = text!.count
if let newPosition2 = position(from: beginningOfDocument, offset: arbitraryValue2) {
selectedTextRange = textRange(from: newPosition2, to: newPosition2)
textAlignment = .left
}
}
}
It's called inside the editingChanged() in SkyFloatingTextField.swift:
@objc open func editingChanged() {
updateControl(true)
updateTitleLabel(true)
putCaretAtTheEnd()
}
Hi, The function is working fine. But still a char is visible partially.
This happens if height of SkyFloatingLabelTextField is too small. Setting 50.0 as height resolves this issue.