Commit 027880ba by Daniel Dahan Committed by GitHub

Merge pull request #544 from MGStudio/master

Fix placeholder placement when using left view in textfield.
parents 42e6257c e0c8eced
......@@ -437,7 +437,11 @@ open class TextField: UITextField {
/// Layout the placeholderLabel.
open func layoutPlaceholderLabel() {
if !isEditing && true == text?.isEmpty && isPlaceholderAnimated {
if let leftViewWidth = self.leftView?.frame.size.width {
placeholderLabel.frame = CGRect(x: leftViewWidth, y: bounds.origin.y, width: bounds.size.width - leftViewWidth, height: bounds.size.height)
} else {
placeholderLabel.frame = bounds
}
} else if placeholderLabel.transform.isIdentity {
placeholderLabel.frame = bounds
placeholderLabel.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
......@@ -545,7 +549,7 @@ open class TextField: UITextField {
}
s.placeholderLabel.transform = CGAffineTransform.identity
s.placeholderLabel.x = 0
s.placeholderLabel.x = s.leftView?.frame.size.width ?? 0
s.placeholderLabel.y = 0
s.placeholderLabel.textColor = s.placeholderNormalColor
}) { [weak self] _ in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment