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 { ...@@ -437,7 +437,11 @@ open class TextField: UITextField {
/// Layout the placeholderLabel. /// Layout the placeholderLabel.
open func layoutPlaceholderLabel() { open func layoutPlaceholderLabel() {
if !isEditing && true == text?.isEmpty && isPlaceholderAnimated { if !isEditing && true == text?.isEmpty && isPlaceholderAnimated {
placeholderLabel.frame = bounds 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 { } else if placeholderLabel.transform.isIdentity {
placeholderLabel.frame = bounds placeholderLabel.frame = bounds
placeholderLabel.transform = CGAffineTransform(scaleX: 0.75, y: 0.75) placeholderLabel.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
...@@ -543,9 +547,9 @@ open class TextField: UITextField { ...@@ -543,9 +547,9 @@ open class TextField: UITextField {
guard let s = self else { guard let s = self else {
return return
} }
s.placeholderLabel.transform = CGAffineTransform.identity s.placeholderLabel.transform = CGAffineTransform.identity
s.placeholderLabel.x = 0 s.placeholderLabel.x = s.leftView?.frame.size.width ?? 0
s.placeholderLabel.y = 0 s.placeholderLabel.y = 0
s.placeholderLabel.textColor = s.placeholderNormalColor s.placeholderLabel.textColor = s.placeholderNormalColor
}) { [weak self] _ in }) { [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