The bug is that center aligning in the textfield misplaces the title/placeholder.
But, it worked for the FloatLabelTextView.
As I didn't want to spend much time reading the logic for title placement, I just compared the setTitlePositionForTextAlignment functions in FloatLabelTextField.swift and FloatLabelTextView.swift.
Here is the fix in case anyone is looking for it:
private func setTitlePositionForTextAlignment() {
let r = textRectForBounds(bounds)
var x = r.origin.x
if textAlignment == NSTextAlignment.Center {
// x = r.origin.x + (r.size.width * 0.5) - title.frame.size.width <-- **comment out this line and add the next line.**
x = (frame.size.width - title.frame.size.width) * 0.5 // <-- add this
} else if textAlignment == NSTextAlignment.Right {
x = r.origin.x + r.size.width - title.frame.size.width
}
title.frame = CGRect(x:x, y:title.frame.origin.y, width:title.frame.size.width, height:title.frame.size.height)
}
The bug is that center aligning in the textfield misplaces the title/placeholder. But, it worked for the FloatLabelTextView.
As I didn't want to spend much time reading the logic for title placement, I just compared the setTitlePositionForTextAlignment functions in FloatLabelTextField.swift and FloatLabelTextView.swift.
Here is the fix in case anyone is looking for it: